url-join

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

Library
npm
v5.0.0
366stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
60/100Good
Development Activity64
Maintenance36
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture70
Code Quality82
Innovation55
Learning Curve95

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

Developer Tools · AI Code Assistants · Automation

16,010

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
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

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
67
Dependency
Built with
TypeScript75%
Updated today
TypeScript
99%
Other

LobeHub

AI Assistants · Productivity · Automation

81,816

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
72
Dependency
Built with
TypeScript99%
Updated today
TypeScript
99%
Other

NocoBase

No Code Platforms · Low Code Platforms

23,696

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
65
Dependency
Built with
TypeScript99%
Updated today
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,833

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

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go91%
Updated 3 weeks ago
TypeScript
84%
MIT

Plasmic

CMS · Low Code Platforms · No Code Platforms

6,961

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
65
Dependency
Built with
TypeScript84%
Updated today
Rust
67%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,065

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
66
Dependency
Built with
Rust67%
TypeScript29%
Updated today
JavaScript
86%
AGPL 3.0

SillyTavern

AI Assistants

32,350

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
68
Repo Health
71
Technical
69
Dependency
Built with
JavaScript86%
Updated 2 days ago
TypeScript
87%
Other

strapi

CMS

72,965

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
68
Dependency
Built with
TypeScript87%
JavaScript12%
Updated yesterday

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

Search