You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
3.6 KiB

{"ast":null,"code":"import URL from 'url-parse';\nexport function getFilename(url) {\n var _URL = new URL(url, {}),\n pathname = _URL.pathname;\n return pathname.substring(pathname.lastIndexOf('/') + 1);\n}\nexport function getFileExtension(url) {\n var filename = getFilename(url);\n var dotIndex = filename.lastIndexOf('.');\n return dotIndex > 0 ? filename.substring(dotIndex) : '';\n}\nexport function getManifestBaseUrl(manifestUrl) {\n var urlObject = new URL(manifestUrl, {});\n if (urlObject.protocol === 'exp:') {\n urlObject.set('protocol', 'http:');\n } else if (urlObject.protocol === 'exps:') {\n urlObject.set('protocol', 'https:');\n }\n var directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);\n urlObject.set('pathname', directory);\n urlObject.set('query', '');\n urlObject.set('hash', '');\n return urlObject.href;\n}","map":{"version":3,"sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,WAAW;AAE3B,OAAM,SAAU,WAAW,CAAC,GAAW,EAAA;EACrC,WAAqB,IAAI,GAAG,CAAC,GAAG,EAAE,CAAA,CAAE,CAAC;IAA7B,QAAQ,QAAR,QAAQ;EAChB,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1D;AAEA,OAAM,SAAU,gBAAgB,CAAC,GAAW,EAAA;EAC1C,IAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC;EACjC,IAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC;EAE1C,OAAO,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE;AACzD;AAaA,OAAM,SAAU,kBAAkB,CAAC,WAAmB,EAAA;EACpD,IAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAA,CAAE,CAAC;EAG1C,IAAI,SAAS,CAAC,QAAQ,KAAK,MAAM,EAAE;IACjC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;GACnC,MAAM,IAAI,SAAS,CAAC,QAAQ,KAAK,OAAO,EAAE;IACzC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC;EACpC;EAGD,IAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;EAC1F,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC;EACpC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;EAC1B,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;EAEzB,OAAO,SAAS,CAAC,IAAI;AACvB","sourcesContent":["import URL from 'url-parse';\n\nexport function getFilename(url: string): string {\n const { pathname } = new URL(url, {});\n return pathname.substring(pathname.lastIndexOf('/') + 1);\n}\n\nexport function getFileExtension(url: string): string {\n const filename = getFilename(url);\n const dotIndex = filename.lastIndexOf('.');\n // Ignore leading dots for hidden files\n return dotIndex > 0 ? filename.substring(dotIndex) : '';\n}\n\n/**\n * Returns the base URL from a manifest's URL. For example, given a manifest hosted at\n * https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query\n * parameters and fragments also are removed.\n *\n * For an Expo-hosted project with a manifest hosted at https://exp.host/@user/project/index.exp, the\n * base URL would be https://exp.host/@user/project.\n *\n * We also normalize the \"exp\" protocol to \"http\" to handle internal URLs with the Expo schemes used\n * to tell the OS to open the URLs in the the Expo client.\n */\nexport function getManifestBaseUrl(manifestUrl: string): string {\n const urlObject = new URL(manifestUrl, {});\n\n // Change the scheme to http(s) if it is exp(s)\n if (urlObject.protocol === 'exp:') {\n urlObject.set('protocol', 'http:');\n } else if (urlObject.protocol === 'exps:') {\n urlObject.set('protocol', 'https:');\n }\n\n // Trim filename, query parameters, and fragment, if any\n const directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);\n urlObject.set('pathname', directory);\n urlObject.set('query', '');\n urlObject.set('hash', '');\n\n return urlObject.href;\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}