(url)
| 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) { |
no outgoing calls
no test coverage detected