resolve-url

WebJar for resolve-url

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

resolve-url
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

resolve-url
WebJar for resolve-url
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/lydell/resolve-url

Download resolve-url

How to add to project

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

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.

Deprecated

Is npm bugging you about this module being deprecated? You are probably depending on this module via the source-map-resolve package. For example:

nanomatch > snapdragon > source-map-resolve > resolve-url

The solution is to make your dependency chain update to source-map-resolve version 0.6.0 or later, or switch to dependencies not using source-map-resolve at all.

If you are looking for a way to resolve URLs in the browser, use URL.

Overview

browser support

Like Node.js’ path.resolve/url.resolve for the browser.

var resolveUrl = require("resolve-url")

window.location
// https://example.com/articles/resolving-urls/edit

resolveUrl("remove")
// https://example.com/articles/resolving-urls/remove

resolveUrl("/static/scripts/app.js")
// https://example.com/static/scripts/app.js

// Imagine /static/scripts/app.js contains `//# sourceMappingURL=../source-maps/app.js.map`
resolveUrl("/static/scripts/app.js", "../source-maps/app.js.map")
// https://example.com/static/source-maps/app.js.map

resolveUrl("/static/scripts/app.js", "../source-maps/app.js.map", "../coffee/app.coffee")
// https://example.com/static/coffee/app.coffee

resolveUrl("//cdn.example.com/jquery.js")
// https://cdn.example.com/jquery.js

resolveUrl("http://foo.org/")
// http://foo.org/

Installation

  • npm install resolve-url
  • bower install resolve-url
  • component install lydell/resolve-url

Works with CommonJS, AMD and browser globals, through UMD.

Usage

resolveUrl(...urls)

Pass one or more urls. Resolves the last one to an absolute url, using the previous ones and window.location.

It’s like starting out on window.location, and then clicking links with the urls as href attributes in order, from left to right.

Unlike Node.js’ path.resolve, this function always goes through all of the arguments, from left to right. path.resolve goes from right to left and only in the worst case goes through them all. Should that matter.

Actually, the function is really like clicking a lot of links in series: An actual <a> gets its href attribute set for each url! This means that the url resolution of the browser is used, which makes this module really light-weight.

Also note that this function deals with urls, not paths, so in that respect it has more in common with Node.js’ url.resolve. But the arguments are more like path.resolve.

Development

Tests

First off, run npm install to install testing modules.

npm test lints the code and then gives you a link to open in a browser of choice (using testling).

x-package.json5

package.json, component.json and bower.json are all generated from x-package.json5 by using xpkg. Only edit x-package.json5, and remember to run xpkg before commiting!

License

The X11 (“MIT”) License.

Versions

Version
0.2.1