JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 32888
  • Score
    100M100P100Q154541F
  • License MIT

Like `path.join` but for a URL.

Package Exports

  • proper-url-join

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (proper-url-join) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

proper-url-join

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status Greenkeeper badge

Like path.join but for a URL.

Installation

$ npm install proper-url-join --save-dev

Motivation

There are a lot of packages that attempt to provide this functionality but they all have issues.
This package exists to properly offer the ability to join urls.

Usage

import urlJoin from 'url-join';

urlJoin('foo', 'bar');  // /foo/bar
urlJoin('/foo/', '/bar/');  // /foo/bar
urlJoin('foo', '', 'bar');  // /foo/bar
urlJoin('foo', undefined, 'bar');  // /foo/bar
urlJoin('foo', null, 'bar');  // /foo/bar

urlJoin('foo', 'bar', { leadingSlash: false });  // foo/bar
urlJoin('foo', 'bar', { trailingSlash: true });  // /foo/bar/
urlJoin('foo', 'bar', { leadingSlash: false, trailingSlash: true });  // foo/bar/

Available options:

  • leadingSlash: Add a leading / (defaults to true)
  • trailingSlash: Add a trailing / (defaults to false)

Tests

$ npm test
$ npm test -- --watch during development

License

MIT License