MCPcopy
hub / github.com/allmarkedup/purl / parseUri

Function parseUri

purl.js:39–61  ·  view source on GitHub ↗
( url, strictMode )

Source from the content-addressed store, hash-verified

37 isint = /^[0-9]+$/;
38
39 function parseUri( url, strictMode ) {
40 var str = decodeURI( url ),
41 res = parser[ strictMode || false ? 'strict' : 'loose' ].exec( str ),
42 uri = { attr : {}, param : {}, seg : {} },
43 i = 14;
44
45 while ( i-- ) {
46 uri.attr[ key[i] ] = res[i] || '';
47 }
48
49 // build query and fragment parameters
50 uri.param['query'] = parseString(uri.attr['query']);
51 uri.param['fragment'] = parseString(uri.attr['fragment']);
52
53 // split path and fragement into segments
54 uri.seg['path'] = uri.attr.path.replace(/^\/+|\/+$/g,'').split('/');
55 uri.seg['fragment'] = uri.attr.fragment.replace(/^\/+|\/+$/g,'').split('/');
56
57 // compile a 'base' domain attribute
58 uri.attr['base'] = uri.attr.host ? (uri.attr.protocol ? uri.attr.protocol+'://'+uri.attr.host : uri.attr.host) + (uri.attr.port ? ':'+uri.attr.port : '') : '';
59
60 return uri;
61 }
62
63 function getAttrName( elm ) {
64 var tn = elm.tagName;

Callers 1

purlFunction · 0.85

Calls 1

parseStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…