Path lexical normalize
path-lexical-normalize · version 1.0.0 · File paths (lexical) · free, no key needed
Normalize a path lexically: collapse redundant separators, resolve "." and ".." segments.
Use when you need to: path normalize · normalize file path · collapse dot segments.
Supported
- path normalize
- normalize file path
- collapse dot segments
- resolve dot dot
Not supported
- stat file
- resolve symlinks
- filesystem access
Behavior
- Collapse redundant separators and resolve "." and ".." via lexicalNormalize.
- If allow_above_root is false and normalized result has leading ".." for a relative path, reject with badInput.
- changed: normalized !== original input string.
Input
path(string, required): min length 1; max length 4096format(one of "posix", "windows", "auto", optional)allow_above_root(boolean, optional)
Output
normalized(string, required)format(one of "posix", "windows", required)is_absolute(boolean, required)changed(boolean, required)
Limits
- max path bytes: 4096
Example
Request input:
{
"path": "/a/b/../c/./d"
}
Response:
{
"result": {
"normalized": "/a/c/d",
"format": "posix",
"is_absolute": true,
"changed": true
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "path-lexical-normalize",
"version": "1.0.0",
"input": {
"path": "/a/b/../c/./d"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/path-lexical-normalize/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"path":"/a/b/../c/./d"}'
The machine-readable contract is at /v1/tools/path-lexical-normalize/versions/1.0.0.
CLI
node cli.mjs run path-lexical-normalize 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Path lexical join: Join an array of path segments lexically, resolving absolute reset boundaries and normalizing separators.
- Path lexical parse: Decompose a file path into its lexical components without accessing the filesystem.
- Path lexical common ancestor: Compute the deepest common ancestor directory of a set of paths.
- Path lexical contains: Check whether a child path is lexically inside a parent directory.
- Path lexical relative: Compute the lexical relative path from one path to another without filesystem access.
- Path lexical sanitize: Sanitize an untrusted path to produce a safe relative path, stripping roots, drive letters, traversal segments, and illegal characters.