All Projects → tom-sherman → immurl

tom-sherman / immurl

Licence: MIT license
🔗 A tiny immutable URL library, backed by the native whatwg URL.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to immurl

video thumbnail
This plugin generates thumbnail from video file or URL. It returns image in memory or writes into a file. It offers rich options to control the image format, resolution and quality. Supports iOS and Android.
Stars: ✭ 159 (+591.3%)
Mutual labels:  url
chemin
🥾 A type-safe pattern builder & route matching library written in TypeScript
Stars: ✭ 37 (+60.87%)
Mutual labels:  url
mongoose-slug-updater
Schema-based slug plugin for Mongoose - single/compound - unique over collection/group - nested docs/arrays - relative/abs paths - sync on change: create/save/update/updateOne/updateMany/findOneAndUpdate tracked - $set operator - counter/shortId
Stars: ✭ 37 (+60.87%)
Mutual labels:  url
mnmlurl-extension
[DEPRECATED] 💁 Browser extension for Minimal URL - Modern URL shortener with support for custom alias & can be hosted even in GitHub pages
Stars: ✭ 21 (-8.7%)
Mutual labels:  url
url-normalize
URL normalization for Python
Stars: ✭ 82 (+256.52%)
Mutual labels:  url
applink
A simple router based on scheme for Android
Stars: ✭ 21 (-8.7%)
Mutual labels:  url
linkify
Rust library to find links such as URLs and email addresses in plain text, handling surrounding punctuation correctly
Stars: ✭ 146 (+534.78%)
Mutual labels:  url
seenreq
Generate an object for testing if a request is sent, request is Mikeal's request.
Stars: ✭ 42 (+82.61%)
Mutual labels:  url
node-match-path
Matches a URL against a path. Parameters, wildcards, RegExp.
Stars: ✭ 30 (+30.43%)
Mutual labels:  url
url-regex-safe
Regular expression matching for URL's. Maintained, safe, and browser-friendly version of url-regex. Resolves CVE-2020-7661 for Node.js servers.
Stars: ✭ 59 (+156.52%)
Mutual labels:  url
keyword-extract
简单高效的URL关键词提取工具
Stars: ✭ 15 (-34.78%)
Mutual labels:  url
ST-OpenUri
The ultimate Sublime Text plugin for opening URIs (URLs) in your file.
Stars: ✭ 25 (+8.7%)
Mutual labels:  url
url
A C++ library that implements the URL WhatWG specification
Stars: ✭ 35 (+52.17%)
Mutual labels:  url
django-slugs-example-app
A basic app to show how to add slugs to models
Stars: ✭ 12 (-47.83%)
Mutual labels:  url
url-trailing-slash
Allows enforcing URL routes with or without trailing slash
Stars: ✭ 35 (+52.17%)
Mutual labels:  url
url-survival-check
批量检测URL存活
Stars: ✭ 44 (+91.3%)
Mutual labels:  url
UnboundBL
🛑 DNSBL (adblock) on OPNsense with UnboundBL & Unbound DNS
Stars: ✭ 63 (+173.91%)
Mutual labels:  url
gravatar-url-generator
A fun and friendly generator of Gravatar urls.
Stars: ✭ 44 (+91.3%)
Mutual labels:  url
b23.wtf
Remove tracing parameters from b23.tv/*.
Stars: ✭ 85 (+269.57%)
Mutual labels:  url
UrlManager
Javascript class for getting and setting url parameters
Stars: ✭ 15 (-34.78%)
Mutual labels:  url

immurl

🔗 A tiny (< 500B), 0-dependency, immutable URL library, backed by the native whatwg URL. 🎉 Now with immutable Headers support!

Install

npm install immurl

Because immurl uses the native whatwg URL API under the hood you'll need a polyfill to support environments that don't implement this API eg. IE11.

Usage

ImmutableURL

ImmutableURL works as you expect, it contains all of the properties of the native URL API.

import { ImmutableURL } from 'immurl';

const url = new ImmutableURL('https://example.com');

console.log(url.href); // 'https://example.com'

// Set properties with the .set() method

let newUrl = url.set('pathname', '/login');

// Because the set API is immutable you can chain calls to .set()

newUrl = url.set('pathname', '/bar').set('hash', '#heading'); // https://example.com/bar#heading

ImmutableURLSearchParams

immurl also contains an immutable version of the URLSearchParams API; ImmutableURLSearchParams.

The API for ImmutableURLSearchParams is exactly the same as the native version except the methods that usually mutate (.append(), .delete(), .sort()) return a new ImmutableURLSearchParams instance.

import { ImmutableURLSearchParams } from 'immurl';

let params = new ImmutableURLSearchParams('q=URLUtils.searchParams&topic=api');

params = params.append('foo', 'bar').delete('q'); // topic=api&foo=bar

The searchParams property of ImmutableURL returns an ImmutableURLSearchParams.

const url = new ImmutableURL('https://example.com?foo=bar');

const newParams = url.searchParams
  .append('q', 'search-term')
  .set('foo', 'fuz')
  .sort();

// url.searchParams is unaffected (thanks to immutability 🎉)

// We can pass our newParams into url.set() to create a new url with the updated params
const newUrl = url.set('searchParams', newParams);

// The following code is equvalent to the above

const newUrl2 = url.set(
  'searchParams',
  url.searchParams.append('q', 'search-term').set('foo', 'fuz').sort()
);

ImmutableHeaders

Not strictly related to whatg URLs, but it's shoehorned in here because it's kinda related and they're usually used together.

import { ImmutableHeaders } from 'immurl';

const headers = new ImmutableHeaders({
  foo: 'bar'
});

const newHeaders = headers.set('foo', 'fuz');

console.log(headers.get('foo')); // Logs "bar"
console.log(newHeaders.get('foo')); // Logs "fuz"

API

See the docs at https://immurl.netlify.app/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].