packages/expo-dev-client/plugin/build/generateScheme.js
/*
 * Converts the slug from app configuration to a string that's a valid URI scheme.
 * From RFC3986 Section 3.1.
 * scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
 */
Converts the slug from app configuration to a string that's a valid URI scheme.
Converts the slug from app configuration to a string that ' s a valid URI scheme .
function generateScheme(config) {
    let scheme = config.slug.replace(/[^A-Za-z0-9+\-.]/g, '');
    if (scheme.length === 0) {
        throw new Error('Could not autogenerate a scheme. Please set the "scheme" property in app config.');
    }
    scheme = scheme.toLowerCase();
    return `exp+${scheme}`;
}
function generateScheme ( config ) { let scheme = config . slug . replace ( / [^A-Za-z0-9+\-.] / g , '' ) ; if ( scheme . length === 0 ) { throw new Error ( 'Could not autogenerate a scheme. Please set the "scheme" property in app config.' ) ; } scheme = scheme . toLowerCase ( ) ; return ` ${ scheme } ` ; }
Converts the slug from app configuration to a string that's a valid URI scheme.
Converts the slug from app configuration to a string that ' s a valid URI scheme .
// Remove unallowed characters. Also remove `-` to keep this shorter. // Edge case: if the slug didn't include any allowed characters we may end up with an empty string. // Lowercasing might not be strictly necessary, but let's do it for stylistic purposes. // Add a prefix to avoid leading digits and to distinguish from user-defined schemes.