Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
710 bytes
|
Line | |
---|
1 | # Canonical Path Utility
|
---|
2 |
|
---|
3 | When writing node.js code that must support Windows and *nix OSes, it is sometimes frustrating
|
---|
4 | that path segments are separated differently depending upon the environment.
|
---|
5 |
|
---|
6 | Ironically, we can pass in paths with either separator and the library will normalize it to the
|
---|
7 | current OS's format. But it then returns paths using the current OS's separator.
|
---|
8 |
|
---|
9 | This utility simple wraps the built-in `path` library such that it only ever returns path segments
|
---|
10 | separated by forward slashes (/).
|
---|
11 |
|
---|
12 | ## Installation
|
---|
13 |
|
---|
14 | ```
|
---|
15 | npm install --save canonical-path
|
---|
16 | ```
|
---|
17 |
|
---|
18 | ## Usage
|
---|
19 |
|
---|
20 | ```
|
---|
21 | var path = require('canonical-path');
|
---|
22 |
|
---|
23 | var p = path.normalize('a/b/../c');
|
---|
24 | // p === 'a/c';
|
---|
25 | ```
|
---|
26 |
|
---|
27 | ## Testing
|
---|
28 |
|
---|
29 | ```
|
---|
30 | npm test
|
---|
31 | ``` |
---|
Note:
See
TracBrowser
for help on using the repository browser.