url-join

Joins URL path segments together and normalizes the result, like path.join for URLs

Library
npm
v5.0.0
366 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
54 /100 Fair
Development Activity 44
Maintenance 32
Community 60
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 70
Code Quality 82
Innovation 55
Learning Curve 95

url-join is a tiny, dependency-free utility that joins any number of URL fragments — base URLs, path segments, query strings — into a single, correctly-formatted URL. It handles the fiddly edge cases of manual string concatenation: collapsing duplicate slashes, preserving the protocol’s double-slash, merging multiple query-string fragments with the right separators, and correctly handling file:// and IPv6 host URLs.

The entire implementation is a single ESM function (urlJoin(...args) or urlJoin([args])) with no runtime dependencies, making it a drop-in replacement for the common but error-prone pattern of concatenating strings with template literals or manual slash-trimming.

What You Get

  • A single urlJoin(...parts) function accepting either variadic string arguments or a single array
  • Automatic normalization of duplicate slashes between joined segments
  • Correct handling of protocol double-slashes, file:// triple-slash paths, and IPv6 host brackets
  • Merging of multiple query-string fragments across joined segments into one ?/&-correct query string
  • Zero runtime dependencies and a TypeScript declaration file shipped with the package

Common Use Cases

  • Building a full request URL from a configurable base URL plus a resource path in an API client
  • Combining a CDN or asset base path with per-file paths without manual slash bookkeeping
  • Joining route segments in server-side routing code where paths are assembled dynamically
  • Merging query parameters contributed by different parts of a codebase into one valid query string

Under The Hood

Architecture The library is a single exported function (lib/url-join.js) built around one internal normalize(strArray) helper: it filters empty segments, special-cases a leading bare protocol or leading slash by folding it into the next segment, applies protocol-specific slash rules (file:/// gets three slashes, everything else two), then iterates the remaining segments trimming leading/trailing slashes before rejoining them with single slashes and finally collapsing/re-merging query-string separators (?/&) and any hash fragment.

Tech Stack Pure, dependency-free JavaScript (ESM only, type: module) with no runtime dependencies at all; the sole devDependency is conventional-changelog for release notes. Node’s built-in node --test runner is used directly instead of a third-party test framework, keeping the entire toolchain minimal.

Code Quality The test/tests.js file (323 lines) exercises a large matrix of edge cases — protocol handling, IPv6 hosts, file:// URLs, query-string merging, hash fragments, and empty/whitespace segments — giving strong confidence in correctness for a function whose entire value proposition is handling string-joining edge cases correctly. The implementation itself is a single file with clear inline comments explaining each normalization step, though it favors dense regex-based string manipulation over more explicit parsing, which raises the bar slightly for a newcomer to modify safely.

API Design The API is about as small as possible: one function, accepting either spread arguments or a single array, with no configuration object or options to learn. This makes adoption instantaneous for the common case, though the tradeoff is that any non-default joining behavior (e.g. custom slash handling) isn’t configurable and would require a different tool or a fork.

Used by 10 apps in this directory

TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,787

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 75%
Updated 4 days ago
TypeScript
99%
Other

LobeHub

AI Assistants · Automation · Productivity

82,864

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,377

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 5 days ago
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,895

API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.

View details
81
Repo Health
78
Technical
65
Dependency
Built with
Go 91%
Updated 2 months ago
TypeScript
89%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,048

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 89%
Updated 5 days ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,195

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 6 days ago
JavaScript
86%
AGPL 3.0

SillyTavern

AI Assistants

33,853

The power-user LLM frontend that unifies dozens of AI backends with a rich scripting engine, immersive Visual Novel mode, and a thriving extension ecosystem.

View details
91
Repo Health
71
Technical
67
Dependency
Built with
JavaScript 86%
Updated 1 weeks ago
TypeScript
88%
Other

strapi

CMS

73,243

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 88%
JavaScript 12%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers