Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@googlicius/build-url

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googlicius/build-url

Build url helper

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61
decreased by-83.78%
Maintainers
1
Weekly downloads
 
Created
Source

Build URL

A helper to build url with query params as easy way. Helpful when your application routing or state management based on URL query params.

Installation

npm install @googlicius/build-url

Or Yarn:

yarn add @googlicius/buil-url

Usage

import buildUrl from '@googlicius/build-url';

buildUrl('http://my-website.com/post', {
  queryParams: {
    page: 2,
  },
});

// Output: http://my-website.com/post?page=2

Add another query param

buildUrl('http://my-website.com/post?page=2', {
  queryParams: {
    sort: 'title:asc',
  },
});

// Output: http://my-website.com/post?page=2&sort=title%3Aasc

Input url/path is omitted

buildUrl({
  queryParams: {
    sort: 'title:asc',
  },
});

// Output: /?sort=title%3Aasc

Remove a query param

buildUrl('images?page=2&sort=title:asc', {
  queryParams: {
    page: null,
  },
});

// Output: /images?sort=title%3Aasc

Always returns absolute url

// Assume that current url is: http://awesome-website.com

buildUrl('/posts', {
  returnAbsoluteUrl: true,
  queryParams: {
    page: 2,
  },
});

// Output: http://awesome-website.com/posts?page=2

License

MIT

FAQs

Package last updated on 23 Jul 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc