UNPKG

1.15 kBSource Map (JSON)View Raw
1{"version":3,"sources":["parseUrl.js"],"names":["module","exports","parseUrl","url","scheme","exec","i","length","slashIndex","indexOf","origin","pathname","slice"],"mappings":"AAAAA,MAAM,CAACC,OAAP,GAAiB,SAASC,QAAT,CAAmBC,GAAnB,EAAwB;AACvC,MAAMC,MAAM,GAAG,YAAYC,IAAZ,CAAiBF,GAAjB,CAAf;AACA,MAAIG,CAAC,GAAG,CAAR;;AACA,MAAIF,MAAJ,EAAY;AACVE,IAAAA,CAAC,GAAGF,MAAM,CAAC,CAAD,CAAN,CAAUG,MAAV,GAAmB,CAAvB;AACD;;AACD,MAAMC,UAAU,GAAGL,GAAG,CAACM,OAAJ,CAAY,GAAZ,EAAiBH,CAAjB,CAAnB;;AACA,MAAIE,UAAU,KAAK,CAAC,CAApB,EAAuB;AACrB,WAAO;AACLE,MAAAA,MAAM,EAAEP,GADH;AAELQ,MAAAA,QAAQ,EAAE;AAFL,KAAP;AAID;;AAED,SAAO;AACLD,IAAAA,MAAM,EAAEP,GAAG,CAACS,KAAJ,CAAU,CAAV,EAAaJ,UAAb,CADH;AAELG,IAAAA,QAAQ,EAAER,GAAG,CAACS,KAAJ,CAAUJ,UAAV;AAFL,GAAP;AAID,CAlBD","sourcesContent":["module.exports = function parseUrl (url) {\n const scheme = /^\\w+:\\/\\//.exec(url)\n let i = 0\n if (scheme) {\n i = scheme[0].length + 1\n }\n const slashIndex = url.indexOf('/', i)\n if (slashIndex === -1) {\n return {\n origin: url,\n pathname: '/'\n }\n }\n\n return {\n origin: url.slice(0, slashIndex),\n pathname: url.slice(slashIndex)\n }\n}\n"]}
\No newline at end of file