# extendify/3.2.1/src/Shared/utils/get-url-parameter.js

Extendify, version 3.2.1. 25 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.1/code/src/Shared/utils/get-url-parameter.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.1/raw/src/Shared/utils/get-url-parameter.js
- Modified: 2025-03-13T17:10:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.2.1/code/src/Shared/utils/get-url-parameter.js#L10-L20`.

```javascript
import { sanitizeString } from '@shared/utils/sanitize';

export const getUrlParameter = (parameterName, cleanUrl = true) => {
	const urlParams = new URLSearchParams(window.location.search);
	if (!urlParams.has(parameterName)) return null;

	const sanitizedParameter = sanitizeString(urlParams.get(parameterName));

	if (cleanUrl) {
		urlParams.delete(parameterName);
		const cleanedSearchParameters = urlParams.toString();
		const searchParametersToUrl = cleanedSearchParameters
			? `?${cleanedSearchParameters}`
			: '';

		window.history.replaceState(
			{},
			document.title,
			`${window.location.pathname}${searchParametersToUrl}`,
		);
	}

	return sanitizedParameter;
};

```
