Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preview): filter slugs with special characters to match dev clients exp+<slug> scheme #252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42133,7 +42133,8 @@ function getUpdateGroupQr({ projectId, updateGroupId, appSlug, qrTarget, }) {
if (qrTarget === 'dev-build') {
// While the parameter is called `appScheme`, it's actually the app's slug
// This should only be added when using dev clients as target
url.searchParams.append('appScheme', appSlug);
// See: https://github.com/expo/expo/blob/8ae75dde393e5d2393d446227a1fe2482c75eec3/packages/expo-dev-client/plugin/src/getDefaultScheme.ts#L17
url.searchParams.append('appScheme', appSlug.replace(/[^A-Za-z0-9+\-.]/g, ''));
}
url.searchParams.append('projectId', projectId);
url.searchParams.append('groupId', updateGroupId);
Expand Down
3 changes: 2 additions & 1 deletion src/eas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export function getUpdateGroupQr({
if (qrTarget === 'dev-build') {
// While the parameter is called `appScheme`, it's actually the app's slug
// This should only be added when using dev clients as target
url.searchParams.append('appScheme', appSlug);
// See: https://github.com/expo/expo/blob/8ae75dde393e5d2393d446227a1fe2482c75eec3/packages/expo-dev-client/plugin/src/getDefaultScheme.ts#L17
url.searchParams.append('appScheme', appSlug.replace(/[^A-Za-z0-9+\-.]/g, ''));
}

url.searchParams.append('projectId', projectId);
Expand Down
36 changes: 36 additions & 0 deletions tests/eas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { getUpdateGroupQr } from '../src/eas';

describe(getUpdateGroupQr, () => {
it('returns url for expo-go', () => {
expect(
getUpdateGroupQr({
qrTarget: 'expo-go',
projectId: 'projectId',
updateGroupId: 'updateGroupId',
appSlug: 'appslug',
})
).toBe('https://qr.expo.dev/eas-update?projectId=projectId&groupId=updateGroupId');
});

it('returns url for dev-build', () => {
expect(
getUpdateGroupQr({
qrTarget: 'dev-build',
projectId: 'projectId',
updateGroupId: 'updateGroupId',
appSlug: 'appslug',
})
).toBe('https://qr.expo.dev/eas-update?appScheme=appslug&projectId=projectId&groupId=updateGroupId');
});

it('returns url for dev-build, with `_` in appSlug', () => {
expect(
getUpdateGroupQr({
qrTarget: 'dev-build',
projectId: 'projectId',
updateGroupId: 'updateGroupId',
appSlug: 'hello_world',
})
).toBe('https://qr.expo.dev/eas-update?appScheme=helloworld&projectId=projectId&groupId=updateGroupId');
});
});
Loading