npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

url-parse-modify

v1.0.8

Published

url-parse-modify is a JavaScript library designed for parsing and manipulating URLs easily. It can be used in both browser-based and Node.js applications. This library simplifies the process of working with URLs, allowing you to extract and modify differe

Downloads

46

Readme

Version npm

Npm install

npm i url-parse-modify

Import

import Url from 'url-parse-modify';

Parse url

const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
console.log(url.urlParse)

return:

{
  path: '/3rd-Eden/path/to/resource',
  hash: 'section2',
  protocol: 'http',
  origin: 'http://localhost',
  username: null,
  password: null,
  hostname: 'localhost',
  port: '8080',
  query: { name: 'John', id: '123' }
}

| Property | Description | |-----------|----------------------------------------------------| | hash | The URL hash fragment, can be a string or null. | | protocol | The URL protocol (e.g., "http" or "https"), or null. | | origin | The URL origin (e.g., "https://example.com"), or null. | | username | A username in the URL, can be a string or null. | | password | A password in the URL, can be a string or null. | | hostname | The URL hostname (e.g., "example.com"), or null. | | port | The URL port (e.g., "8080"), can be a string or null. | | query | An object representing URL query parameters. | | path | The URL path, can be a string or null. |

toString()

const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
console.log(url.toString())

//http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2

get(key)

const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
const host = url.get('hostname')
console.log(host)
//localhost

| Key | Description | |------------|----------------------------------------------------| | 'hash' | Represents the URL hash fragment. | | 'protocol' | Represents the URL protocol (e.g., "http" or "https"). | | 'origin' | Represents the URL origin (e.g., "https://example.com"). | | 'username' | Represents a username in the URL. | | 'password' | Represents a password in the URL. | | 'hostname' | Represents the URL hostname (e.g., "example.com"). | | 'port' | Represents the URL port (e.g., "8080"). | | 'query' | Represents URL query parameters as an object. | | 'path' | Represents the URL path. |

set(key,value)

const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
url.set('hostname', 'google.com')
console.log(url.toString())
//http://google.com:8080/3rd-Eden/path/to/resource?name=John&id=123#section2

| Parameter | Description | |------------|----------------------------------------------------| | key | A string literal representing the property to be set. Valid options include: 'hash', 'protocol', 'origin', 'username', 'password', 'hostname', 'port', 'query', or 'path'. | | value | The value to set for the specified property. It can be either a string or an object(query) with string keys and any values. |

const url = new Url('http://localhost:8080/3rd-Eden/path/to/resource?name=John&id=123#section2')
url.set('query', { name: 'rakib', id: '5345345435' })
console.log(url.toString())
//http://localhost:8080/3rd-Eden/path/to/resource?name=rakib&id=5345345435#section2