README.md
 1  file-uri-to-path
 2  ================
 3  ### Convert a `file:` URI to a file path
 4  [![Build Status](https://github.com/TooTallNate/file-uri-to-path/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/file-uri-to-path/actions?workflow=Node+CI)
 5  
 6  Accepts a `file:` URI and returns a regular file path suitable for use with the
 7  `fs` module functions.
 8  
 9  
10  Installation
11  ------------
12  
13  Install with `npm`:
14  
15  ``` bash
16  $ npm install file-uri-to-path
17  ```
18  
19  
20  Example
21  -------
22  
23  ``` js
24  var uri2path = require('file-uri-to-path');
25  
26  uri2path('file://localhost/c|/WINDOWS/clock.avi');
27  // "c:\\WINDOWS\\clock.avi"
28  
29  uri2path('file:///c|/WINDOWS/clock.avi');
30  // "c:\\WINDOWS\\clock.avi"
31  
32  uri2path('file://localhost/c:/WINDOWS/clock.avi');
33  // "c:\\WINDOWS\\clock.avi"
34  
35  uri2path('file://hostname/path/to/the%20file.txt');
36  // "\\\\hostname\\path\\to\\the file.txt"
37  
38  uri2path('file:///c:/path/to/the%20file.txt');
39  // "c:\\path\\to\\the file.txt"
40  ```
41  
42  
43  API
44  ---
45  
46  ### fileUriToPath(String uri) → String
47  
48  
49  
50  License
51  -------
52  
53  (The MIT License)
54  
55  Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
56  
57  Permission is hereby granted, free of charge, to any person obtaining
58  a copy of this software and associated documentation files (the
59  'Software'), to deal in the Software without restriction, including
60  without limitation the rights to use, copy, modify, merge, publish,
61  distribute, sublicense, and/or sell copies of the Software, and to
62  permit persons to whom the Software is furnished to do so, subject to
63  the following conditions:
64  
65  The above copyright notice and this permission notice shall be
66  included in all copies or substantial portions of the Software.
67  
68  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.