hasQueryParam

Check whether a URL contains a query parameter with the given key, returning a boolean so you can branch on the presence of a flag.

Usage

hasQueryParam checks whether a URL contains a specific query parameter.

import { hasQueryParam } from '@movk/core'

hasQueryParam('https://example.com?page=1', 'page') // true
hasQueryParam('https://example.com?page=1', 'sort') // false
hasQueryParam('https://example.com?flag', 'flag') // true (valueless parameter)

API

hasQueryParam(url, key)

Check whether a URL contains a specific query parameter.

Parameters

url
string required
The URL string.
key
string required
The parameter key.

Returns

returns
boolean
Whether the parameter is present.

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License