resolve-pathname

WebJar for resolve-pathname

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

resolve-pathname
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

resolve-pathname
WebJar for resolve-pathname
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mjackson/resolve-pathname

Download resolve-pathname

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/resolve-pathname/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>resolve-pathname</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/resolve-pathname/
implementation 'org.webjars.npm:resolve-pathname:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/resolve-pathname/
implementation ("org.webjars.npm:resolve-pathname:3.0.0")
'org.webjars.npm:resolve-pathname:jar:3.0.0'
<dependency org="org.webjars.npm" name="resolve-pathname" rev="3.0.0">
  <artifact name="resolve-pathname" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='resolve-pathname', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "resolve-pathname" % "3.0.0"
[org.webjars.npm/resolve-pathname "3.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

resolve-pathname Travis npm package

resolve-pathname resolves URL pathnames identical to the way browsers resolve the pathname of an <a href> value. The goals are:

  • 100% compatibility with browser pathname resolution
  • Pure JavaScript implementation (no DOM dependency)

Installation

Using npm:

$ npm install --save resolve-pathname

Then, use as you would anything else:

// using ES6 modules
import resolvePathname from 'resolve-pathname';

// using CommonJS modules
var resolvePathname = require('resolve-pathname');

The UMD build is also available on unpkg:

<script src="https://unpkg.com/resolve-pathname"></script>

You can find the library on window.resolvePathname.

Usage

import resolvePathname from 'resolve-pathname';

// Simply pass the pathname you'd like to resolve. Second
// argument is the path we're coming from, or the current
// pathname. It defaults to "/".
resolvePathname('about', '/company/jobs'); // /company/about
resolvePathname('../jobs', '/company/team/ceo'); // /company/jobs
resolvePathname('about'); // /about
resolvePathname('/about'); // /about

// Index paths (with a trailing slash) are also supported and
// work the same way as browsers.
resolvePathname('about', '/company/info/'); // /company/info/about

// In browsers, it's easy to resolve a URL pathname relative to
// the current page. Just use window.location! e.g. if
// window.location.pathname == '/company/team/ceo' then
resolvePathname('cto', window.location.pathname); // /company/team/cto
resolvePathname('../jobs', window.location.pathname); // /company/jobs

Prior Work

  • url.resolve - node's url.resolve implementation for full URLs
  • resolve-url - A DOM-dependent implementation of the same algorithm

Versions

Version
3.0.0
3.0.0-beta.0
2.2.0
2.0.2