/** * Location Utils. * * @export * @abstract * @class LocationUtils */ export abstract class LocationUtils { /** * Get URL Search Params as an object from `location.search`. * * The values inside the Search Params are decoded using * `decodeURIComponent`. * * @static * @return {*} Search Params. * @memberof LocationUtils */ public static getURLSearchParams(): { [key: string]: string } { const params: { [key: string]: string } = {}; let search = window.location.search || ""; if (search == null || search.length === 0) { return {}; } if (search.includes("?")) { search = search.slice(1); } const pairs = search.split("&"); for (const pair of pairs) { const parts = pair.split("="); const key = parts[0]; if (parts.length > 0) { params[key] = decodeURIComponent(parts[1]); } else { params[key] = ""; } } return params; } }