Skip to content

Construct a url by passing query params with encoded as uri and get the keys embedded into url as decoded values

Notifications You must be signed in to change notification settings

AmanAgarwal041/med-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

med-url

Construct a url by passing query params as encoded uri or get the keys embedded into url as decoded values.

Installation

npm install --save med-url

Usage

Import the module to your code

import MedUrl from 'med-url'; // Functionalities to MedUrl variable

Functions

set(url, options)

MedUrl.set(url, options)

Folowing are the params to be passed :

option used for
url Url or object for construction of url
options Object for passing query params

get(url, key)

MedUrl.get(url, key)

Folowing are the params to be passed :

option used for
url Url or object for construction of url
key Key for getting value of a parameter

Usage

MedUrl.set('https://google.co', { query: { a: 1, b: 'site' } })
// "https://google.co?a=1&b=site"
MedUrl.set('https://google.co?c=89', { query: { a: 1, b: 'site' } })
// "https://google.co?c=89&a=1&b=site"
MedUrl.set('https://google.co?c=89', { query: { a: 1, b: 'site google' } })
// "https://google.co?c=89&a=1&b=site%20google"
MedUrl.get("https://google.co?c=89&a=1&b=site%20google")
// {c: "89", a: "1", b: "site google"}
MedUrl.get("https://google.co?c=89&a=1&b=site%20google", "d")
// undefined
MedUrl.get("https://google.co?c=89&a=1&b=site%20google", "c")
// "89"

Links

You can visit some links for reference:

Organisation

Gradeup

About

Construct a url by passing query params with encoded as uri and get the keys embedded into url as decoded values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published