Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// We don't have a manifest in bare workflow except after publishing, so warn people in development.
if (!Constants.manifest) {
console.warn(
'Linking.makeUrl is not supported in bare workflow. Switch to using your scheme string directly.'
);
return '';
}
let scheme = 'exp';
const manifestScheme = manifest.scheme ?? manifest?.detach?.scheme;
if (Constants.appOwnership === 'standalone' && manifestScheme) {
scheme = manifestScheme;
} else if (Constants.appOwnership === 'standalone' && !manifestScheme) {
throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
} else if (Constants.appOwnership === 'expo' && !manifestScheme) {
console.warn(
'Linking requires that you provide a `scheme` in app.json for standalone apps - if it is left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Add a `scheme` to silence this warning. Learn more about Linking at https://docs.expo.io/versions/latest/workflow/linking/'
);
}
let hostUri = getHostUri() || '';
if (usesCustomScheme() && isExpoHosted()) {
hostUri = '';
}
if (path) {
if (isExpoHosted() && hostUri) {
path = `/--/${removeLeadingSlash(path)}`;
}
if (!path.startsWith('/')) {
path = `/${path}`;
return encodeURI(`${origin}${outputPath}${queryString}`);
}
// We don't have a manifest in bare workflow except after publishing, so warn people in development.
if (!Constants.manifest) {
console.warn(
'Linking.makeUrl is not supported in bare workflow. Switch to using your scheme string directly.'
);
return '';
}
let scheme = 'exp';
const manifestScheme = manifest.scheme ?? manifest?.detach?.scheme;
if (Constants.appOwnership === 'standalone' && manifestScheme) {
scheme = manifestScheme;
} else if (Constants.appOwnership === 'standalone' && !manifestScheme) {
throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
} else if (Constants.appOwnership === 'expo' && !manifestScheme) {
console.warn(
'Linking requires that you provide a `scheme` in app.json for standalone apps - if it is left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Add a `scheme` to silence this warning. Learn more about Linking at https://docs.expo.io/versions/latest/workflow/linking/'
);
}
let hostUri = getHostUri() || '';
if (usesCustomScheme() && isExpoHosted()) {
hostUri = '';
}
if (path) {
if (isExpoHosted() && hostUri) {
it('should raise an error when lead to an incompatible type', () => {
if (Constants.platform && Constants.platform.ios) {
// $ExpectError
(Constants.platform.ios.buildNumber: number);
// $ExpectError
(Constants.platform.ios.platform: number);
// $ExpectError
(Constants.platform.ios.model: number);
// $ExpectError
(Constants.platform.ios.userInterfaceIdiom: number);
// $ExpectError
(Constants.platform.ios.systemVersion: number);
}
});
});
it('should have versionCode prop', () => {
if (Constants.platform && Constants.platform.android) {
(Constants.platform.android.versionCode: number);
// $ExpectError: check any
(Constants.platform.android.versionCode: boolean);
}
});
});
it('should raise an error when lead to an incompatible type', () => {
// $ExpectError
(Constants.debugMode: 'ups...');
// $ExpectError
(Constants.deviceName: 'ups...');
// $ExpectError
(Constants.deviceYearClass: 'ups...');
// $ExpectError
(Constants.experienceUrl: 'ups...');
// $ExpectError
(Constants.expoRuntimeVersion: 'ups...');
// $ExpectError
(Constants.expoVersion: 'ups...');
// $ExpectError
(Constants.isDetached: 'ups...');
// $ExpectError
(Constants.intentUri: 'ups...');
// $ExpectError
(Constants.installationId: 'ups...');
// $ExpectError
(Constants.isDevice: 'ups...');
it('should raise an error when lead to an incompatible type', () => {
// $ExpectError
(Constants.deviceId: boolean);
// $ExpectError
(Constants.linkingUrl: boolean);
});
});
it('should passes when used properly', () => {
Constants.getWebViewUserAgentAsync().then(ua => {
if (ua !== null) {
(ua: string);
// $ExpectError: check any
(ua: number);
} else {
(ua: null);
}
});
});
});
it('should raise an error when lead to an incompatible type', () => {
// $ExpectError
(Constants.debugMode: 'ups...');
// $ExpectError
(Constants.deviceName: 'ups...');
// $ExpectError
(Constants.deviceYearClass: 'ups...');
// $ExpectError
(Constants.experienceUrl: 'ups...');
// $ExpectError
(Constants.expoRuntimeVersion: 'ups...');
// $ExpectError
(Constants.expoVersion: 'ups...');
// $ExpectError
(Constants.isDetached: 'ups...');
// $ExpectError
(Constants.intentUri: 'ups...');
// $ExpectError
(Constants.installationId: 'ups...');
// $ExpectError
(Constants.isDevice: 'ups...');
// $ExpectError
(Constants.isHeadless: 'ups...');
// $ExpectError
(Constants.linkingUri: 'ups...');
// $ExpectError
(Constants.isDetached: 'ups...');
// $ExpectError
(Constants.intentUri: 'ups...');
// $ExpectError
(Constants.installationId: 'ups...');
// $ExpectError
(Constants.isDevice: 'ups...');
// $ExpectError
(Constants.isHeadless: 'ups...');
// $ExpectError
(Constants.linkingUri: 'ups...');
// $ExpectError
(Constants.sessionId: 'ups...');
// $ExpectError
(Constants.statusBarHeight: 'ups...');
// $ExpectError
(Constants.systemVersion: 'ups...');
// $ExpectError
(Constants.systemFonts: 'ups...');
});
});
// Requires interaction (sign in popup)
modules.push(optionalRequire(() => require('./tests/GoogleSignIn')));
// Popup to request device's location which uses Google's location service
modules.push(optionalRequire(() => require('./tests/Location')));
// Fails to redirect because of malformed URL in published version with release channel parameter
modules.push(optionalRequire(() => require('./tests/Linking')));
// Has uncontrolled view controllers
modules.push(require('./tests/SMS'));
// Requires permission
modules.push(optionalRequire(() => require('./tests/Calendar')));
modules.push(optionalRequire(() => require('./tests/Permissions')));
modules.push(optionalRequire(() => require('./tests/MediaLibrary')));
modules.push(optionalRequire(() => require('./tests/Notifications')));
modules.push(optionalRequire(() => require('./tests/Battery')));
if (Constants.isDevice) {
modules.push(optionalRequire(() => require('./tests/Brightness')));
}
// Crashes app when mounting component
modules.push(optionalRequire(() => require('./tests/Video')));
// "sdkUnversionedTestSuite failed: java.lang.NullPointerException: Attempt to invoke interface method
// 'java.util.Map org.unimodules.interfaces.taskManager.TaskInterface.getOptions()' on a null object reference"
modules.push(optionalRequire(() => require('./tests/TaskManager')));
// Audio tests are flaky in CI due to asynchronous fetching of resources
modules.push(optionalRequire(() => require('./tests/Audio')));
// The Camera tests are flaky on iOS, i.e. they fail randomly
if (Constants.isDevice && Platform.OS === 'android')
modules.push(optionalRequire(() => require('./tests/Camera')));
}
if (Constants.isDevice) {
modules.push(optionalRequire(() => require('./tests/Cellular')));
modules.push(optionalRequire(() => require('./tests/BarCodeScanner')));