Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
universal-parse-url
Advanced tools
Changelog
Readme
A universal URL parser for Node.js and browser environments with a minimal footprint (gzipped only 600 bytes for the browser version).
Install with npm
:
npm install --save universal-parse-url
Note: The installed node module also includes a d.ts
file, and thus works out of the box with TypeScript.
import { parseURL } from 'universal-parse-url';
const url = parseURL('http://www.example.com:1234/foo?bar=1#baz');
The resulting url
object looks like this:
{
hash: '#baz',
host: 'www.example.com:1234',
hostname: 'www.example.com',
href: 'http://www.example.com:1234/foo?bar=1#baz',
pathname: '/foo',
port: '1234',
protocol: 'http:',
search: '?bar=1'
}
parseURL
just delegates to URL.parse.document.createElement('a')
).parseURL
is called, the href
attribute of this element is set to the given url string.If you plan on targeting browser environments as well, you need to use a bundler like Webpack, Browserify or Rollup (with rollup-plugin-node-resolve) that makes use of the browser
field in the package.json
.
To keep universal-parse-url
as small and simple as possible, only the URL details that are available in Node’s URL
object as well as HTMLAnchorElement
are supported (see the above example).
FAQs
A universal URL parser for Node.js and browser environments with a minimal footprint.
The npm package universal-parse-url receives a total of 104 weekly downloads. As such, universal-parse-url popularity was classified as not popular.
We found that universal-parse-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.