Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@availity/resolve-url
Advanced tools
Resolve URLs to absolute URI/IRI.
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 . There is an open issue to make the library compatible with IE11: Issue #5
npm install @av/resolve-url --save
relative()
relative
: Relative url to be converted to full urlbase
(optional): Base url used to convert the relative url. If base URL is not provided it is calculated from window.location.href
.import { resolveUrl } from "@availity/resolve-url";
resolveUrl({relative: '/a/b', base: 'https://example.com/})
// Outputs https://example.com/a/b
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
resolveUrl({relative: '/a/b'})
// Outputs https://example.com/a/b
The following examples were adapted from relative-to-absolute-iri
Fragments/hashes in relative URIs are also taken into account.
resolve('#abc', 'http://base.org/'); // Outputs 'http://base.org/#abc'
Invalid base URIs cause an error to be thrown.
resolve('abc', 'def'); // Error
When a relative IRI starts with a //
, then the scheme of the base IRI will be used.
resolve('//abc', 'http://base.org/'); // Outputs 'http://abc'
Relative URIs that starts with a /
erase the path of the base IRI.
resolve('/abc/def/', 'http://base.org/123/456/'); // Outputs 'http://base.org/abc/def/'
Relative URIs that point to the current directory (.
)
or parent directory (..
) are collapsed.
resolve('xyz', 'http://aa/parent/parent/../../a'); // Outputs 'http://aa/xyz'
resolve('xyz', 'http://aa/././a'); // Outputs 'http://aa/xyz'
URI
- Uniform Resource Identifier allows ASCII charactersIRI
- Internationalized Resource Identifier allows Unicode typesetFAQs
Resolve absolute url from relative urls
The npm package @availity/resolve-url receives a total of 775 weekly downloads. As such, @availity/resolve-url popularity was classified as not popular.
We found that @availity/resolve-url demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.