Skip to content

defaultJoin

reference
1 min readUpdated

Kind: Function

Source: src/middleware/serve-static/path.ts

Part of: Middleware

defaultJoin does not support Windows paths and always uses / separators. If you need Windows path support, please use join exported from node:path etc. instead.

defaultJoin combines path segments for the static-file middleware using / separators. It is intended for URL-style or POSIX-style paths and does not support Windows path conventions; use join from node:path when Windows support is needed.

Signature

ts
function defaultJoin(paths: string[]): string

Parameters

NameType
pathsstring[]

Returns: string

Diagram

mermaid
graph LR
  A[Path segments] --> B[defaultJoin]
  B --> C[Slash-normalized path]
  C --> D[Static file lookup]

Usage

ts
import { defaultJoin } from './path'

const filePath = defaultJoin('/public/', '/assets', 'app.js')

console.log(filePath)
// /public/assets/app.js

AI Coding Instructions

  • Keep path segments in URL or POSIX format when calling defaultJoin.
  • Do not use defaultJoin for Windows filesystem paths.
  • Use join from node:path when the runtime must support platform-specific separators.
  • Pass the joined result into static-file path resolution rather than manually concatenating segments.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • ServeStaticOptionssrc/middleware/serve-static/index.ts:13

Was this page helpful?

Download as PDF
defaultJoin — Hono (narrator proof)