GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hckhanh/fast-url: a high-performance URL building library that makes constructing URLs safe and convenient

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

1,004 Commits
1,004 Commits

Folders and files

NameName
Last commit message
Last commit date
.changeset
.changeset
 
 
.github
.github
 
 
benchmark
benchmark
 
 
benchmarks
benchmarks
 
 
docs
docs
 
 
src
src
 
 
test
test
 
 
tools
tools
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.knip.json
.knip.json
 
 
.syncpackrc.json
.syncpackrc.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
OPTIMIZATION_GUIDE.md
OPTIMIZATION_GUIDE.md
 
 
QUERYSTRING_UPDATE_SUMMARY.md
QUERYSTRING_UPDATE_SUMMARY.md
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
biome.json
biome.json
 
 
bun.lock
bun.lock
 
 
bunfig.toml
bunfig.toml
 
 
codecov.yml
codecov.yml
 
 
context7.json
context7.json
 
 
jsr.json
jsr.json
 
 
mise.toml
mise.toml
 
 
package.json
package.json
 
 
renovate.json
renovate.json
 
 
tsconfig.json
tsconfig.json
 
 
tsdown.config.ts
tsdown.config.ts
 
 
vitest.config.mts
vitest.config.mts
 
 

Repository files navigation

fast-url NPM Downloads JSR

fast-url

A folk version of the urlcat focuses on performance and simplicity. Build correct URLs easily. A fast, minimal fork of urlcat focused on performance and simplicity.

Test codecov Quality Gate Status Bundle Size CodSpeed

fast-url is a tiny JavaScript/TypeScript library that makes building URLs convenient and prevents common mistakes.

Documentation

https://docs.khanh.id/fast-url

Features

  • Lightweight: Only one dependency (fast-querystring) and minimal bundle size
  • Type safe: Written in TypeScript with full type definitions
  • URL safe: Automatically escapes parameters and handles edge cases
  • Unicode-aware: Uses codePointAt for proper Unicode handling, including graceful encoding of lone surrogates
  • Flexible: Multiple ways to build URLs for different use cases

Installation

# Using JSR (recommended for Deno)
deno add jsr:@hckhanh/fast-url

# Using bun
bun add fast-url

# Using npm
npm install fast-url

Usage

Basic usage example Basic usage example (dark mode)

Basic URL building

import { createUrl } from "fast-url";

// Path parameters
createUrl("https://api.example.com", "/users/:id", { id: 123 });
// → 'https://api.example.com/users/123'

// Query parameters
createUrl("https://api.example.com", "/users", { limit: 10, offset: 20 });
// → 'https://api.example.com/users?limit=10&offset=20'

// Combined path and query parameters
createUrl("https://api.example.com", "/users/:id/posts", { id: 123, limit: 10 });
// → 'https://api.example.com/users/123/posts?limit=10'

CommonJS

const { createUrl } = require("fast-url");

Utility functions

import { query, subst, join } from "fast-url";

// Build query strings
query({ name: "John", age: 30 });
// → 'name=John&age=30'

// Substitute path parameters
subst("/users/:id/posts/:postId", { id: 123, postId: 456 });
// → '/users/123/posts/456'

// Join URL parts
join("https://api.example.com/", "/", "/users");
// → 'https://api.example.com/users'

API

createUrl(baseUrl, pathTemplate, params?)

Build a complete URL by combining a base URL, path template, and parameters.

createUrl(baseTemplate, params)

Use a single template containing path parameters; unused params become query parameters.

query(params)

Build a query string from an object of key-value pairs.

subst(template, params)

Substitute path parameters in a template string.

join(part1, separator, part2)

Join two URL parts with exactly one separator.

Why fast-url?

Building URLs manually is error-prone:

// ❌ Error-prone manual approach
const url = `${baseUrl}/users/${id}/posts?limit=${limit}&offset=${offset}`;
// Issues: double slashes, unescaped parameters, complex concatenation
// ✅ Clean and safe with fast-url
const url = createUrl(baseUrl, "/users/:id/posts", { id, limit, offset });

fast-url handles:

  • Automatic parameter escaping
  • Proper URL segment joining
  • Clean separation of path and query parameters

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

About

a high-performance URL building library that makes constructing URLs safe and convenient

docs.khanh.id/fast-url

Topics

apiapi-restcreate-urlfastoptimizedquerystringurlurl-builderurl-parser

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.