Skip to content

Replacement for abandoned library uri-js aka URI.js: based on standard js URL and without punycode dependency

Notifications You must be signed in to change notification settings

andreinwald/uri-js-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URI parsing/validating/resolving library

Replacement for abandoned library uri-js aka "URI.js"

NPM

  • Based on Node.js and browser URL api
  • 99% compatible with original URI.js library
  • Solves "The punycode module is deprecated" warning in Node
  • Tested with libraries: ESLint, Webpack, Ajv

Usage

NPM

Add to your package.json

{
  "overrides": {
    "uri-js": "npm:uri-js-replace"
  }
}

and run

npm update

Yarn

{
  "overrides": {
    "uri-js": "yarn:uri-js-replace"
  }
}

Library usage examples

Parsing

import * as URI from "uri-js";

URI.parse("uri://user:[email protected]:123/one/two.three?q1=a1&q2=a2#body");
//returns:
//{
//  scheme : "uri",
//  userinfo : "user:pass",
//  host : "example.com",
//  port : 123,
//  path : "/one/two.three",
//  query : "q1=a1&q2=a2",
//  fragment : "body"
//}

Serializing

URI.serialize({scheme : "http", host : "example.com", fragment : "footer"}) === "http://example.com/#footer"

Normalizing

URI.normalize("URI://www.example.org/red%09ros\xE9#red") === "uri://www.example.org/red%09ros%C3%A9#red"

Tests

All tests copied from original repository

vitest

Generating d.ts files

npm i -g typescript
tsc

NPM

https://www.npmjs.com/package/uri-js-replace

About

Replacement for abandoned library uri-js aka URI.js: based on standard js URL and without punycode dependency

Resources

Stars

Watchers

Forks