Debian Codegraph @

src/cmd/go/internal/web/url_other_test.go

raw
1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build !windows
6
7 package web
8
9 var urlTests = []struct {
10 url string
11 filePath string
12 canonicalURL string // If empty, assume equal to url.
13 wantErr string
14 }{
15 // Examples from RFC 8089:
16 {
17 url: `file:///path/to/file`,
18 filePath: `/path/to/file`,
19 },
20 {
21 url: `file:/path/to/file`,
22 filePath: `/path/to/file`,
23 canonicalURL: `file:///path/to/file`,
24 },
25 {
26 url: `file://localhost/path/to/file`,
27 filePath: `/path/to/file`,
28 canonicalURL: `file:///path/to/file`,
29 },
30
31 // We reject non-local files.
32 {
33 url: `file://host.example.com/path/to/file`,
34 wantErr: "file URL specifies non-local host",
35 },
36 }