JSPM

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

Node's URL module plus relative pathing

Package Exports

  • url2

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 (url2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

URL2

This module builds upon the existing URL module in NodeJS, but adds relative(source, target) which returns the shortest relative path between any two equally qualified URL’s. If the paths are not equally qualified, it returns the target.

In addition, this package augments the URL object definition as returned by parse and consumed by format.

  • pathname is broken down into
    • root: whether the path is qualified from the root of the domain.
    • relative: the relative path, from the root if pathname is qualified from the domain root.
      • directories: an array of path components
      • file: the name of the file, or null if the URL points to a directory, indicated by a final slash.

Additionally, format uses the path property if it exists, instead of pathname and search.


Based on my earlier work for Narwhal.

Copyright 2012 Kristopher Michael Kowal. All rights reserved. MIT License