Skip to content

extractPureURI

Extracts only the URI from a path with optional query and fragments.

For example, all these inputs return /path:

  • /path
  • /path?query=thing
  • /path#fragment
  • /path?query=thing#fragment

Available since v1.0.1

import { extractPureURI } from '@helpers4/url';
extractPureURI(path: string): string
ParameterTypeDescription
pathstringA complete path, without the server part.

string — The path without its query string or fragment.

extractPureURI('https://www.google.com/?q=search');
// => 'https://www.google.com/'

View on npm