MCPcopy Create free account
hub / github.com/WICG/webpackage / convertPathToURL

Function convertPathToURL

go/bundle/cmd/gen-bundle/fromdir.go:52–67  ·  view source on GitHub ↗
(path string, baseDir string, baseURL *url.URL)

Source from the content-addressed store, hash-verified

50}
51
52func convertPathToURL(path string, baseDir string, baseURL *url.URL) (string, error) {
53 relPath, err := filepath.Rel(baseDir, path)
54 if err != nil {
55 return "", fmt.Errorf("Cannot make relative path for %q: %v", path, err)
56 }
57 var result *url.URL
58 if baseURL != nil {
59 result, err = baseURL.Parse(filepath.ToSlash(relPath))
60 } else {
61 result, err = url.Parse(filepath.ToSlash(relPath))
62 }
63 if err != nil {
64 return "", fmt.Errorf("Failed to construct URL for %s. err: %v", path, err)
65 }
66 return result.String(), nil
67}
68
69// responseWriter implements http.ResponseWriter.
70type responseWriter struct {

Callers 1

fromDirFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected