-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[menu-bar] Refactor deep-link routes to comply with the URL spec (#151)
* [menu-bar] Refactor deep-link routes to comply with the URL spec * Add changelog entry * Update tests to use triple slashes * Update Expo auth to use triple slashes * Update local server to handle triple slashes
- Loading branch information
1 parent
6a56f6c
commit 40a16db
Showing
7 changed files
with
559 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { URLType, identifyAndParseDeeplinkURL } from '../parseUrl'; | ||
|
||
jest.mock('../../modules/Storage', () => ({ | ||
saveSessionSecret: jest.fn(), | ||
})); | ||
|
||
describe('identifyAndParseDeeplinkURL', () => { | ||
describe('Auth URLs', () => { | ||
it('should support Auth callback URL from expo.dev', () => { | ||
const authCallbackURL = | ||
'expo-orbit:///auth?username_or_email=gabrieldonadel&session_secret=%7B%22id%22%3A%22XXXXXXXX-XXXX-XXXX-XXXXX-XXXXXXXXXXXX%22%2C%22version%22%3A1%2C%22expires_at%22%3A0000000000000%7D'; | ||
|
||
expect(identifyAndParseDeeplinkURL(authCallbackURL)).toEqual({ | ||
urlType: URLType.AUTH, | ||
url: authCallbackURL, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Build URLs', () => { | ||
it('Should identiy expo.dev/artifacts URLs as Build URLs', () => { | ||
const artifactDeeplinkURL = | ||
'expo-orbit://expo.dev/artifacts/eas/v3WshxGCF87UzsHSxfRnAh.tar.gz'; | ||
|
||
expect(identifyAndParseDeeplinkURL(artifactDeeplinkURL)).toEqual({ | ||
urlType: URLType.EXPO_BUILD, | ||
url: artifactDeeplinkURL.replace('expo-orbit://', 'https://'), | ||
}); | ||
}); | ||
|
||
it('Should parse url parameter from /download route', () => { | ||
const artifactURL = 'https://expo.dev/artifacts/eas/v3WshxGCF87UzsHSxfRnAh.tar.gz'; | ||
const artifactDeeplinkURL = `expo-orbit:///download/?url=${encodeURIComponent(artifactURL)}`; | ||
|
||
expect(identifyAndParseDeeplinkURL(artifactDeeplinkURL)).toEqual({ | ||
urlType: URLType.EXPO_BUILD, | ||
url: artifactURL, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Update URLs', () => { | ||
it('Should parse url parameter from /update route', () => { | ||
const updateURL = 'https://u.expo.dev/update/addecbed-f477-4a75-bd88-0732dc928fe9'; | ||
const updateDeeplinkURL = `expo-orbit:///update?url=${encodeURIComponent(updateURL)}`; | ||
|
||
expect(identifyAndParseDeeplinkURL(updateDeeplinkURL)).toEqual({ | ||
urlType: URLType.EXPO_UPDATE, | ||
url: updateURL, | ||
}); | ||
}); | ||
|
||
it('Should throw if url parameter is not present', () => { | ||
const updateDeeplinkURL = `expo-orbit:///update`; | ||
|
||
expect(() => identifyAndParseDeeplinkURL(updateDeeplinkURL)).toThrowError(); | ||
}); | ||
}); | ||
|
||
describe('Snack URLs', () => { | ||
it('Should identiy exp.host URLs as Snack URLs', () => { | ||
const snackDeeplinkURL = 'expo-orbit://exp.host/@gabrieldonadel/ec41d8+IH9vwTGYrg'; | ||
|
||
expect(identifyAndParseDeeplinkURL(snackDeeplinkURL)).toEqual({ | ||
urlType: URLType.SNACK, | ||
url: snackDeeplinkURL.replace('expo-orbit://', 'exp://'), | ||
}); | ||
}); | ||
|
||
it('Should parse url parameter from /snack route', () => { | ||
const snackURL = | ||
'exp://staging-u.expo.dev/2dce2748-c51f-4865-bae0-392af794d60a?runtime-version=exposdk%3A50.0.0&channel-name=production&snack-channel=Hhhqw6NhFw'; | ||
const snackDeeplinkURL = `expo-orbit:///snack?url=${encodeURIComponent(snackURL)}`; | ||
|
||
expect(identifyAndParseDeeplinkURL(snackDeeplinkURL)).toEqual({ | ||
urlType: URLType.SNACK, | ||
url: snackURL, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Unsuported URLs', () => { | ||
it('Should throw an error when the URL route is not supported', () => { | ||
const unsuportedURL = 'expo-orbit:///some-future-route'; | ||
|
||
expect(() => identifyAndParseDeeplinkURL(unsuportedURL)).toThrowError(); | ||
}); | ||
|
||
it('Should throw an error when the URL is invalid', () => { | ||
const unsuportedURL = '::::?///aklsdmalksjdaoijoeqw'; | ||
|
||
expect(() => identifyAndParseDeeplinkURL(unsuportedURL)).toThrowError(); | ||
}); | ||
}); | ||
|
||
describe('Unknown URLs', () => { | ||
it('Should identiy non-expo domains that are not using specific routes as Unknown URLs', () => { | ||
const unknownURL = | ||
'expo-orbit://github.com/expo/orbit/releases/download/expo-orbit-v1.0.2/expo-orbit.v1.0.2.zip'; | ||
|
||
expect(identifyAndParseDeeplinkURL(unknownURL)).toEqual({ | ||
urlType: URLType.UNKNOWN, | ||
url: unknownURL.replace('expo-orbit://', 'https://'), | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.