MCPcopy Create free account
hub / github.com/CSAILVision/gandissect / urlString

Method urlString

client/ts/etc/URLHandler.ts:71–90  ·  view source on GitHub ↗

* Generates an URL string from a map of url parameters * @param {{}} urlParameters - the map of parameters * @returns {string} - an URI string

(urlParameters: object)

Source from the content-addressed store, hash-verified

69 * @returns {string} - an URI string
70 */
71 static urlString(urlParameters: object) {
72 const attr = [];
73 Object.keys(urlParameters).forEach(k => {
74 const v = urlParameters[k];
75 if (v !== undefined) {
76 let value = v;
77 if (Array.isArray(v)) value = '..' + v.join(',');
78 attr.push(encodeURI(k + '=' + value))
79 }
80 });
81
82
83 const url = window.location.pathname;
84 let res = url.substring(url.lastIndexOf('/') + 1);
85 if (attr.length > 0) {
86 res += '?' + attr.join('&')
87 }
88
89 return res;
90 }
91
92 static updateURLParam(key: string, value: string | any[], addToBrowserHistory = true) {
93 const currentParams = URLHandler.parameters;

Callers 1

updateUrlMethod · 0.45

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected