1.0.0 • Published 1 year ago

pathbob v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

pathbob

Simple path/URL builder.

An alternative to pathcat. pathbob is a more efficient solution as it parses your path once and returns a template.

Highlights

  • Typesafe
  • Fast
  • Zero dependencies

Install

pnpm add pathbob

Usage

import { parse } from "pathbob";

// this is typesafe 🤯
const template = parse("https://test.com/:id");
const url = template({ id: "abc" }); // https://test.com/abc

// with path instead

const template = parse("https://test.com", "/:id");
const url = template({ id: "abc" }); // https://test.com/abc

// extra values passed to the template automatically become query params!
const template = parse("https://test.com", "/:id");
const url = template({ id: "abc", page: 1 }); // https://test.com/abc?page=1
1.0.0

1 year ago