summaryrefslogtreecommitdiffstats
path: root/node_modules/file-uri-to-path/test
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/file-uri-to-path/test')
-rw-r--r--node_modules/file-uri-to-path/test/test.js24
-rw-r--r--node_modules/file-uri-to-path/test/tests.json13
2 files changed, 37 insertions, 0 deletions
diff --git a/node_modules/file-uri-to-path/test/test.js b/node_modules/file-uri-to-path/test/test.js
new file mode 100644
index 0000000..79305dc
--- /dev/null
+++ b/node_modules/file-uri-to-path/test/test.js
@@ -0,0 +1,24 @@
+
+var sep = require('path').sep || '/';
+var assert = require('assert');
+var uri2path = require('../');
+var tests = require('./tests.json');
+
+describe('file-uri-to-path', function () {
+
+ Object.keys(tests).forEach(function (uri) {
+
+ // the test cases were generated from Windows' PathCreateFromUrlA() function.
+ // On Unix, we have to replace the path separator with the Unix one instead of
+ // the Windows one.
+ var expected = tests[uri].replace(/\\/g, sep);
+
+ it('should convert ' + JSON.stringify(uri) + ' to ' + JSON.stringify(expected),
+ function () {
+ var actual = uri2path(uri);
+ assert.equal(actual, expected);
+ });
+
+ });
+
+});
diff --git a/node_modules/file-uri-to-path/test/tests.json b/node_modules/file-uri-to-path/test/tests.json
new file mode 100644
index 0000000..b935a63
--- /dev/null
+++ b/node_modules/file-uri-to-path/test/tests.json
@@ -0,0 +1,13 @@
+{
+ "file://host/path": "\\\\host\\path",
+ "file://localhost/etc/fstab": "\\etc\\fstab",
+ "file:///etc/fstab": "\\etc\\fstab",
+ "file:///c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
+ "file://localhost/c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
+ "file:///c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
+ "file://localhost/c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
+ "file://hostname/path/to/the%20file.txt": "\\\\hostname\\path\\to\\the file.txt",
+ "file:///c:/path/to/the%20file.txt": "c:\\path\\to\\the file.txt",
+ "file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc": "C:\\Documents and Settings\\davris\\FileSchemeURIs.doc",
+ "file:///C:/caf%C3%A9/%C3%A5r/d%C3%BCnn/%E7%89%9B%E9%93%83/Ph%E1%BB%9F/%F0%9F%98%B5.exe": "C:\\café\\år\\dünn\\牛铃\\Phở\\😵.exe"
+}