@mapbox/link-to-location

    1.0.0 • Public • Published

    @mapbox/link-to-location

    Convert a link (HTMLAnchorElement or URL) to an object with pathname, hash, and search properties. Uses the browser's native link parsing to avoid unnecessary code.

    Installation

    npm install @mapbox/link-to-location
    

    API

    linkToLocation

    linkToLocation(input)

    Returns an object with three properties with string values: pathname, hash, and search.

    input

    Type: HTMLAnchorElement | string.

    Either the DOM element itself or a URL.

    Example

    const linkToLocation = require('link-to-location');
     
    linkToLocation('http://user:pw@foo.bar.baz/qux?quux=grault#fred');
    /*
      {
        pathname: 'foo.bar.baz/qux',
        hash: '#fred',
        search: '?quux=grault'
      }
    */

    Keywords

    none

    Install

    npm i @mapbox/link-to-location

    DownloadsWeekly Downloads

    327

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • mapbox-machine-user
    • mapbox-npm-ci
    • mapbox-npm-advanced-actions
    • mapbox-npm-09
    • mapbox-npm-08
    • mapbox-npm-07
    • mapbox-npm-06
    • mapbox-npm-05
    • mapbox-npm-04
    • mapbox-npm-03
    • mapbox-npm-02
    • mapbox-npm-01
    • mapbox-npm
    • mapbox-admin