@wireapp/commons
Advanced tools
Comparing version 4.4.10 to 4.5.0
@@ -12,10 +12,12 @@ { | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@swc/core": "^1.3.10", | ||
"@swc/jest": "^0.2.23", | ||
"@types/babel__core": "^7", | ||
"@types/babel__preset-env": "^7", | ||
"@types/fs-extra": "9.0.13", | ||
"@types/jest": "29.2.0", | ||
"@types/node": "^18.11.2", | ||
"@types/jest": "^29.2.0", | ||
"@types/platform": "1.3.4", | ||
"jest": "29.2.1", | ||
"jest-environment-jsdom": "29.2.1" | ||
"@types/rimraf": "^3", | ||
"jest": "^29.2.1", | ||
"rimraf": "^3.0.2" | ||
}, | ||
@@ -42,7 +44,7 @@ "description": "Collection of common components that are used across Wire web applications.", | ||
"test": "jest", | ||
"test:coverage": "yarn test --coverage", | ||
"test:watch": "yarn test --watch" | ||
"test:coverage": "yarn test", | ||
"test:watch": "yarn g:jest --watch" | ||
}, | ||
"version": "4.4.10", | ||
"gitHead": "28544331b51d4f6371ff71802271ecaa079da803" | ||
"version": "4.5.0", | ||
"gitHead": "1944c0993e0b7117d3334ffb381556d08a049ddf" | ||
} |
export declare function pathWithParams(path: string, additionalParams?: Record<string, any>, whitelistParams?: string[], search?: string): string; | ||
export declare function paramsToRecord(params: string): Record<string, any>; | ||
/** | ||
* Looks for a given parameter by name in the query part of the URL of the current window's location. | ||
* @param parameterName the name of the parameter to search for | ||
* @param search the source to look at for the parameter, defaults to window.location.search | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
export declare function getURLParameter(parameterName: string, search?: string): string; | ||
/** | ||
* Looks for a given parameter by name in the hash part of the URL of the current window's location. | ||
* @param parameterName the name of the parameter to search for | ||
* @param hash the source to look for at the parameter, defaults to window.location.hash | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
export declare function getURLParameterFromHash(parameterName: string, hash?: string): string; | ||
/** | ||
* Looks for a given parameter by name in the hash and query part of the URL of the current window's location. | ||
* Findings in the hash part are preferend ver the query part. | ||
* Empty values are considered a valid value. | ||
* @param parameterName the name of the parameter to search for | ||
* @param hash the "hash" source to look for at the parameter, defaults to window.location.hash | ||
* @param search the "search" source to look at for the parameter, defaults to window.location.search | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
export declare function getURLParameterFromAny(parameterName: string, hash?: string, search?: string): string; | ||
export declare function hasURLParameter(parameterName: string, search?: string): boolean; |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasURLParameter = exports.getURLParameter = exports.paramsToRecord = exports.pathWithParams = void 0; | ||
exports.hasURLParameter = exports.getURLParameterFromAny = exports.getURLParameterFromHash = exports.getURLParameter = exports.paramsToRecord = exports.pathWithParams = void 0; | ||
function pathWithParams(path, additionalParams, whitelistParams, search = window.location.search) { | ||
@@ -47,2 +47,8 @@ const params = paramsToRecord(search); | ||
exports.paramsToRecord = paramsToRecord; | ||
/** | ||
* Looks for a given parameter by name in the query part of the URL of the current window's location. | ||
* @param parameterName the name of the parameter to search for | ||
* @param search the source to look at for the parameter, defaults to window.location.search | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
function getURLParameter(parameterName, search = window.location.search) { | ||
@@ -52,2 +58,38 @@ return new URLSearchParams(search).get(parameterName) || ''; | ||
exports.getURLParameter = getURLParameter; | ||
/** | ||
* Looks for a given parameter by name in the hash part of the URL of the current window's location. | ||
* @param parameterName the name of the parameter to search for | ||
* @param hash the source to look for at the parameter, defaults to window.location.hash | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
function getURLParameterFromHash(parameterName, hash = window.location.hash) { | ||
// window.location.hash always starts with # | ||
if (hash.length <= 1 || hash[0] !== '#') { | ||
return ''; | ||
} | ||
return new URLSearchParams(hash.substring(1)).get(parameterName) || ''; | ||
} | ||
exports.getURLParameterFromHash = getURLParameterFromHash; | ||
/** | ||
* Looks for a given parameter by name in the hash and query part of the URL of the current window's location. | ||
* Findings in the hash part are preferend ver the query part. | ||
* Empty values are considered a valid value. | ||
* @param parameterName the name of the parameter to search for | ||
* @param hash the "hash" source to look for at the parameter, defaults to window.location.hash | ||
* @param search the "search" source to look at for the parameter, defaults to window.location.search | ||
* @returns the first found parameter or an empty string | ||
*/ | ||
function getURLParameterFromAny(parameterName, hash = window.location.hash, search = window.location.search) { | ||
// getURLParameterFromHash cannot be used here, as it will always return an empty string, even if the value is not set. | ||
// a decision whether the value was set or not is then no longer possible. | ||
// window.location.hash always starts with # | ||
if (hash.length > 1 && hash[0] === '#') { | ||
const result = new URLSearchParams(hash.substring(1)).get(parameterName); | ||
if (result !== null) { | ||
return result; | ||
} | ||
} | ||
return getURLParameter(parameterName, search); | ||
} | ||
exports.getURLParameterFromAny = getURLParameterFromAny; | ||
function hasURLParameter(parameterName, search = window.location.search) { | ||
@@ -54,0 +96,0 @@ return !!new URLSearchParams(search).has(parameterName); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109330
49
1315
13