Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastly/as-url

Package Overview
Dependencies
Maintainers
45
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastly/as-url

![npm version](https://img.shields.io/npm/v/@fastly/as-url) ![npm downloads per month](https://img.shields.io/npm/dm/@fastly/as-url)

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
45
Created
Source

@fastly/as-url

npm version npm downloads per month

AssemblyScript library to implement the WHATWG URL Standard, similar to the JavaScript URL Web API.

Installation

@fastly/as-url is available as a npm package. You can install @fastly/as-url in your AssemblyScript project by running:

npm install --save @fastly/as-url

Quick Start

This package attempts to be an implementation of the JavaScript URL Web API. Thus, the JavaScript URL Web API documentation could also act as a helpful getting started guide. However, while most features are implemented, some features are still in development (e.g URLSearchParams). Please see the reference documentation in the reference-docs directory for the full documentation.

import { URL } from '@fastly/as-url';

// Parse a complex absolute URL
const myComplexUrlString = 'https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash';
const url = new URL(myComplexUrlString);

let protocol = url.protocol; // "https:"
let username = url.username; // "user"
let password = url.password; // "pass"
let hostname = url.hostname; // "sub.example.com"
let port = url.port; // "8080"
let host = url.host; // "sub.example.com:8080"
let origin = url.origin // "https://sub.example.com:8080"
let pathname = url.pathname; // "/p/a/t/h"
let search = url.search; // "?query=string"
let hash = url.hash; // "#hash"
let href = url.href; // "https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash"

// Parse a relative URL
const relativeUrl = new URL(
  "../../p/a/t/h?query=string#hash",
  "https://fastly.com/path1/path2"
);

let relativeUrlHref = relativeUrl.href; // https://fastly.com/p/a/t/h?query=string#hash

Also, feel free to look through the tests for additional examples.

Reference API

The Reference API documentation can be found in the reference-docs/ directory.

Changelog

The changelog can be found here.

Security

If you happen to find any security issues, please see the Fastly Security Reporting Page, or feel free to send an email to: security@fastly.com

We plan to disclose any found security vulnerabilites per the npm security reporting guidelines. Note that communications related to security issues in Fastly-maintained OSS as described here are distinct from Fastly Security Advisories.

Motivation

This library was built to be used as a dependency for @fastly/as-compute.

This library is based on the WHATWG URL Standard and strives to match the JavaScript URL Web API that Node.js 's URL library implements.

However, the goal of this library is not to be a 1-to-1 implementation of the Node URL API. The goal of this library is to enable sharing very similar, if not identical, URL code between Fastly's Compute@Edge platform and popular JavaScript platforms like Web Browsers and Node.

License

Apache-2.0 WITH LLVM-exception

FAQs

Package last updated on 09 Feb 2022

Did you know?

Socket

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.

Install

Related posts

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