paths that always use forward slashes
npm install canonical-path
|77||downloads in the last day|
|1 082||downloads in the last week|
|2 618||downloads in the last month|
|Version||0.0.2 last updated 3 months ago|
|Keywords||path, forward, slashes, OS|
Canonical Path Utility
When writing node.js code that must support Windows and *nix OSes, it is sometimes frustrating that path segments are separated differently depending upon the environment.
Ironically, we can pass in paths with either separator and the library will normalize it to the current OS's format. But it then returns paths using the current OS's separator.
This utility simple wraps the built-in
path library such that it only ever returns path segments
separated by forward slashes (/).
npm install --save canonical-path
var path = require('canonical-path'); var p = path.normalize('a/b/../c'); // p === 'a/c';