1
2
3
4
5 package web
6
7 var urlTests = []struct {
8 url string
9 filePath string
10 canonicalURL string
11 wantErr string
12 }{
13
14
15 {
16 url: `file://laptop/My%20Documents/FileSchemeURIs.doc`,
17 filePath: `\\laptop\My Documents\FileSchemeURIs.doc`,
18 },
19 {
20 url: `file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc`,
21 filePath: `C:\Documents and Settings\davris\FileSchemeURIs.doc`,
22 },
23 {
24 url: `file:///D:/Program%20Files/Viewer/startup.htm`,
25 filePath: `D:\Program Files\Viewer\startup.htm`,
26 },
27 {
28 url: `file:///C:/Program%20Files/Music/Web%20Sys/main.html?REQUEST=RADIO`,
29 filePath: `C:\Program Files\Music\Web Sys\main.html`,
30 canonicalURL: `file:///C:/Program%20Files/Music/Web%20Sys/main.html`,
31 },
32 {
33 url: `file://applib/products/a-b/abc_9/4148.920a/media/start.swf`,
34 filePath: `\\applib\products\a-b\abc_9\4148.920a\media\start.swf`,
35 },
36 {
37 url: `file:////applib/products/a%2Db/abc%5F9/4148.920a/media/start.swf`,
38 wantErr: "file URL missing drive letter",
39 },
40 {
41 url: `C:\Program Files\Music\Web Sys\main.html?REQUEST=RADIO`,
42 wantErr: "non-file URL",
43 },
44
45
46
47 {
48 url: `file://D:/Program Files/Viewer/startup.htm`,
49 wantErr: "file URL encodes volume in host field: too few slashes?",
50 },
51
52
53
54
55
56 {
57 url: `file:///C:/exampleㄓ.txt`,
58 filePath: `C:\exampleㄓ.txt`,
59 canonicalURL: `file:///C:/example%E3%84%93.txt`,
60 },
61 {
62 url: `file:///C:/example%E3%84%93.txt`,
63 filePath: `C:\exampleㄓ.txt`,
64 },
65
66
67
68
69
70
71 {
72 url: `file:c:/path/to/file`,
73 filePath: `c:\path\to\file`,
74 canonicalURL: `file:///c:/path/to/file`,
75 },
76
77
78
79 {
80 url: `file://host.example.com/Share/path/to/file.txt`,
81 filePath: `\\host.example.com\Share\path\to\file.txt`,
82 },
83
84
85
86 {
87 url: `file:////host.example.com/path/to/file`,
88 wantErr: "file URL missing drive letter",
89 },
90 {
91 url: `file://///host.example.com/path/to/file`,
92 wantErr: "file URL missing drive letter",
93 },
94 }
95
View as plain text