be1274e463e7b2ef32d400eac990353b.json
3.78 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.getFilename=getFilename;exports.getFileExtension=getFileExtension;exports.getManifestBaseUrl=getManifestBaseUrl;var _urlParse=_interopRequireDefault(require(\"url-parse\"));function getFilename(url){var _ref=new _urlParse.default(url,{}),pathname=_ref.pathname;return pathname.substring(pathname.lastIndexOf('/')+1);}function getFileExtension(url){var filename=getFilename(url);var dotIndex=filename.lastIndexOf('.');return dotIndex>0?filename.substring(dotIndex):'';}function getManifestBaseUrl(manifestUrl){var urlObject=new _urlParse.default(manifestUrl,{});if(urlObject.protocol==='exp:'){urlObject.set('protocol','http:');}else if(urlObject.protocol==='exps:'){urlObject.set('protocol','https:');}var directory=urlObject.pathname.substring(0,urlObject.pathname.lastIndexOf('/')+1);urlObject.set('pathname',directory);urlObject.set('query','');urlObject.set('hash','');return urlObject.href;}","map":{"version":3,"sources":["../src/AssetUris.ts"],"names":[],"mappings":"oQAAA,2DAEM,QAAU,CAAA,WAAV,CAAsB,GAAtB,CAAiC,UAChB,GAAI,kBAAJ,CAAQ,GAAR,CAAa,EAAb,CADgB,CAC7B,QAD6B,MAC7B,QAD6B,CAErC,MAAO,CAAA,QAAQ,CAAC,SAAT,CAAmB,QAAQ,CAAC,WAAT,CAAqB,GAArB,EAA4B,CAA/C,CAAP,CACD,CAEK,QAAU,CAAA,gBAAV,CAA2B,GAA3B,CAAsC,CAC1C,GAAM,CAAA,QAAQ,CAAG,WAAW,CAAC,GAAD,CAA5B,CACA,GAAM,CAAA,QAAQ,CAAG,QAAQ,CAAC,WAAT,CAAqB,GAArB,CAAjB,CAEA,MAAO,CAAA,QAAQ,CAAG,CAAX,CAAe,QAAQ,CAAC,SAAT,CAAmB,QAAnB,CAAf,CAA8C,EAArD,CACD,CAaK,QAAU,CAAA,kBAAV,CAA6B,WAA7B,CAAgD,CACpD,GAAM,CAAA,SAAS,CAAG,GAAI,kBAAJ,CAAQ,WAAR,CAAqB,EAArB,CAAlB,CAGA,GAAI,SAAS,CAAC,QAAV,GAAuB,MAA3B,CAAmC,CACjC,SAAS,CAAC,GAAV,CAAc,UAAd,CAA0B,OAA1B,EACD,CAFD,IAEO,IAAI,SAAS,CAAC,QAAV,GAAuB,OAA3B,CAAoC,CACzC,SAAS,CAAC,GAAV,CAAc,UAAd,CAA0B,QAA1B,EACD,CAGD,GAAM,CAAA,SAAS,CAAG,SAAS,CAAC,QAAV,CAAmB,SAAnB,CAA6B,CAA7B,CAAgC,SAAS,CAAC,QAAV,CAAmB,WAAnB,CAA+B,GAA/B,EAAsC,CAAtE,CAAlB,CACA,SAAS,CAAC,GAAV,CAAc,UAAd,CAA0B,SAA1B,EACA,SAAS,CAAC,GAAV,CAAc,OAAd,CAAuB,EAAvB,EACA,SAAS,CAAC,GAAV,CAAc,MAAd,CAAsB,EAAtB,EAEA,MAAO,CAAA,SAAS,CAAC,IAAjB,CACD","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://expo.io/@user/project/index.exp, the\n * base URL would be https://expo.io/@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":"script"}