edit-url

1.0.1 • Public • Published

Edit URL

Utility function that allows sync and async manipulations on URL strings.

Features

  • Fully tested
  • Asynchronous manipulations
  • ES6

Installation

$ npm install --save edit-url

Usage

Import

const editURL = require('edit-url');

Sync

editURL('http://google.com/', (obj) => obj.query.q = "Node.JS"); // http://google.com/?q=Node.JS

Async

editURL('http://localhost/', (obj, cb) => {
    findAvailablePort((port)=> {
     obj.port = port;
    });
}), (edited) => {
    console.info(edited); // http://localhost:14036/
});

Dependencies

It uses Node's url module and has no external dependency.

Mocha is use for the tests

Package Sidebar

Install

npm i edit-url

Weekly Downloads

48

Version

1.0.1

License

MIT

Last publish

Collaborators

  • romainbessuges