@infotorg/build-url

2.0.0 • Public • Published

build-url

Build an URL by joining provided parts and removing trailing slash

API documentation

Installation

npm install @infotorg/build-url

Usage

As a parameter(s) an array with url parts or just strings can be provided.

import { buildUrl } from '@infotorg/build-url';

// How url is fixed
const normalizedUrl = buildUrl('https://example.com/');

console.log(normalizedUrl);
// https://example.com

// How url is built from two strings
const normalizedUrl = buildUrl('https://example.com', 'chunk');

console.log(normalizedUrl);
// https://example.com/chunk

// How url is built by joining an array's indexes
const normalizedUrl = buildUrl(['https://example.com', 'chunk']);

console.log(normalizedUrl);
// https://example.com/chunk

Tests

Tests are written with jest. They can be run with npm:

npm run test
LICENSE: MIT
AUTHOR: Lukasz Sitnik

Package Sidebar

Install

npm i @infotorg/build-url

Weekly Downloads

94

Version

2.0.0

License

MIT

Unpacked Size

869 kB

Total Files

44

Last publish

Collaborators

  • grzegorzizyk
  • olesya.kogivchak
  • oleksandr.chuprynin
  • lukaszsitnik
  • coder.ua