@wordpress/url
Version:
WordPress URL utilities.
22 lines (20 loc) • 496 B
text/typescript
/**
* Internal dependencies
*/
import { getQueryArg } from './get-query-arg';
/**
* Determines whether the URL contains a given query arg.
*
* @param url URL.
* @param arg Query arg name.
*
* @example
* ```js
* const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
* ```
*
* @return Whether or not the URL contains the query arg.
*/
export function hasQueryArg( url: string, arg: string ): boolean {
return getQueryArg( url, arg ) !== undefined;
}