src/cmd/go/internal/web/url_other.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 | import ( |
| 10 | "errors" |
| 11 | "path/filepath" |
| 12 | ) |
| 13 | |
| 14 | func convertFileURLPath(host, path string) (string, error) { |
| 15 | switch host { |
| 16 | case "", "localhost": |
| 17 | default: |
| 18 | return "", errors.New("file URL specifies non-local host") |
| 19 | } |
| 20 | return filepath.FromSlash(path), nil |
| 21 | } |