2019-04-25 12:11:42 -06:00
|
|
|
// +build go1.13
|
|
|
|
|
2020-04-10 07:56:06 -06:00
|
|
|
// Copyright 2020 The Go Authors. All rights reserved.
|
2019-04-25 12:11:42 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-04-10 07:56:06 -06:00
|
|
|
package proxydir
|
2019-04-25 12:11:42 -06:00
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-04-10 07:56:06 -06:00
|
|
|
// ToURL returns the file uri for a proxy directory.
|
|
|
|
func ToURL(dir string) string {
|
2019-04-25 12:11:42 -06:00
|
|
|
// file URLs on Windows must start with file:///. See golang.org/issue/6027.
|
|
|
|
path := filepath.ToSlash(dir)
|
|
|
|
if !strings.HasPrefix(path, "/") {
|
|
|
|
path = "/" + path
|
|
|
|
}
|
|
|
|
return "file://" + path
|
|
|
|
}
|