1. url2
Node's URL module plus relative pathing
url2
Package: url2
Created by: kriskowal
Last modified: Wed, 12 Jul 2023 19:10:07 GMT
Version: 1.0.4
Downloads: 256,479
Repository: https://github.com/kriskowal/url2

Install

npm install url2
yarn add url2

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

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code