Socket
Socket
Sign inDemoInstall

@availity/resolve-url

Package Overview
Dependencies
Maintainers
12
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/resolve-url - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

is-absolute-url.d.ts

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [1.1.1](https://github.com/Availity/sdk-js/compare/@availity/resolve-url@1.1.0...@availity/resolve-url@1.1.1) (2019-10-21)
**Note:** Version bump only for package @availity/resolve-url
# [1.1.0](https://github.com/Availity/sdk-js/compare/@availity/resolve-url@1.0.3...@availity/resolve-url@1.1.0) (2019-04-29)

@@ -8,0 +16,0 @@

5

package.json
{
"name": "@availity/resolve-url",
"version": "1.1.0",
"version": "1.1.1",
"description": "Resolve absolute url from relative urls",
"main": "resolve-url.js",
"types": "resolve-url.d.ts",
"keywords": [

@@ -15,3 +16,3 @@ "url",

},
"gitHead": "8127bfe691a8bf980e4ab1764740232140ccb664"
"gitHead": "d376afc731f9cfc8287accd22e20aacb5c035f2d"
}

78

README.md

@@ -5,4 +5,6 @@ # resolve-url

[![Version](https://img.shields.io/npm/v/@availity/resolve-url.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/resolve-url)
This library resolves relative IRIs to absolute IRIs given a base IRI, conforming to [RFC3986](https://www.ietf.org/rfc/rfc3986.txt). The code was borrowed from [relative-to-absolute-iri
](https://github.com/rubensorks/relative-to-absolute-iri.js). There is an open issue to make the library compatible with IE11: [Issue #5](https://github.com/rubensworks/relative-to-absolute-iri.js/issues/5)
](https://github.com/rubensorks/relative-to-absolute-iri.js). ~There is an open issue to make the library compatible with IE11: [Issue #5](https://github.com/rubensworks/relative-to-absolute-iri.js/issues/5)~

@@ -15,74 +17,2 @@ ## Installation

## `relative()`
### Params
- **`relative`**: Relative url to be converted to full url
- **`base`** (_optional_): Base url used to convert the relative url. If base URL is not provided it is calculated from `window.location.href`.
## Usage
```js
import { resolveUrl } from "@availity/resolve-url";
resolveUrl({relative: '/a/b', base: 'https://example.com/})
// Outputs https://example.com/a/b
```
### URLs
When `base` option is not provided, this package will calculate the base from `window.location.href`. The example below returns server relative url if hostname was `https:example.com`
```js
resolveUrl({relative: '/a/b'})
// Outputs https://example.com/a/b
```
> The following examples were adapted from [relative-to-absolute-iri
> ](https://github.com/rubensworks/relative-to-absolute-iri.js)
### Hashes
Fragments/hashes in relative URIs are also taken into account.
```javascript
resolve('#abc', 'http://base.org/'); // Outputs 'http://base.org/#abc'
```
### Invalid base URI
Invalid base URIs cause an error to be thrown.
```javascript
resolve('abc', 'def'); // Error
```
### Protocol Relative
When a relative IRI starts with a `//`, then the scheme of the base IRI will be used.
```javascript
resolve('//abc', 'http://base.org/'); // Outputs 'http://abc'
```
### Root-Relative
Relative URIs that starts with a `/` erase the path of the base IRI.
```javascript
resolve('/abc/def/', 'http://base.org/123/456/'); // Outputs 'http://base.org/abc/def/'
```
### Relative Directory Traversal
Relative URIs that point to the current directory (`.`)
or parent directory (`..`) are collapsed.
```javascript
resolve('xyz', 'http://aa/parent/parent/../../a'); // Outputs 'http://aa/xyz'
resolve('xyz', 'http://aa/././a'); // Outputs 'http://aa/xyz'
```
## Notes
- `URI` - Uniform Resource Identifier allows ASCII characters
- `IRI` - Internationalized Resource Identifier allows Unicode typeset
## [Documentation](https://availity.github.io/sdk-js/features/resolve-url)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc