MCPcopy Create free account
hub / github.com/zhongsp/TypeScript / parseURL

Function parseURL

docs/searcher.js:68–91  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

66
67 // Helper to parse a url into its building blocks.
68 function parseURL(url) {
69 var a = document.createElement('a');
70 a.href = url;
71 return {
72 source: url,
73 protocol: a.protocol.replace(':',''),
74 host: a.hostname,
75 port: a.port,
76 params: (function(){
77 var ret = {};
78 var seg = a.search.replace(/^\?/,'').split('&');
79 var len = seg.length, i = 0, s;
80 for (;i<len;i++) {
81 if (!seg[i]) { continue; }
82 s = seg[i].split('=');
83 ret[s[0]] = s[1];
84 }
85 return ret;
86 })(),
87 file: (a.pathname.match(/\/([^/?#]+)$/i) || [,''])[1],
88 hash: a.hash.replace('#',''),
89 path: a.pathname.replace(/^([^/])/,'/$1')
90 };
91 }
92
93 // Helper to recreate a url string from its building blocks.
94 function renderURL(urlobject) {

Callers 2

doSearchOrMarkFromUrlFunction · 0.85
setSearchUrlParametersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected