PageSourceSearch

https://dyreklinikkenrungstedvej.dk/functions/reconstruct_url.js?version=278202601

js dyreklinikkenrungstedvej.dk collected 2026-10-05 23:37:27 UTC 1,760 bytes, 34 lines download raw bytes

1/**
2 * @description
3 	Takes URL and an object of one or more parameters, where the keys are the parameter names and the values are parameter values, then returns the URL,
4	 reconstructed with those parameters. If null or blank string is supplied as value, the parameter will be removed from the URL.
5	Fully supports hashtags in URL (these will be preserved).
6 * @param {string} strUrl
7 * @param {Object} objNewParams
8 * @return string
9 * @copyright 2016
10 */
11
12function reconstruct_url(strUrl, objNewParams) {
13	if (typeof strUrl === "undefined") throw new Error("URL is required as string");
14	if (typeof objNewParams !== "object") throw new Error("URL parameter(s) required as an object with keys and values");
15	strUrl = strUrl.toString().trim();
16	const arrUrl = strUrl.split("#");
17	strUrl = arrUrl.shift();
18	const strCleanUrl = strUrl.substring(0, strUrl.indexOf("?") > -1 ? strUrl.indexOf("?") : undefined);
19	const arrExistingParams = strUrl.indexOf("?") > -1 ? strUrl.substring(strUrl.indexOf("?") + 1).split("&") : [];
20	let objExistingParams = {};
21	for (let i = 0; i < arrExistingParams.length; i++) {
22		const arrExistingParamChunk = arrExistingParams[i].split("=");
23		objExistingParams[arrExistingParamChunk[0]] = arrExistingParamChunk[1] || null;
24	}
25	objNewParams = $.extend(objExistingParams, objNewParams);
26	let arrNewParamChunks = [];
27	for (let strParamName in objNewParams) {
28		if (typeof objNewParams[strParamName] === "undefined" || objNewParams[strParamName] === null || !objNewParams[strParamName].toString().mb_length()) {
29			continue;
30		}
31		arrNewParamChunks.push(strParamName+"="+objNewParams[strParamName]);
32	}
33	return strCleanUrl+(arrNewParamChunks.length ? "?"+arrNewParamChunks.join("&") : "")+(arrUrl.length ? "#"+arrUrl.join("#") : "");
34}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.