Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/internal/web

     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  // +build !windows
     7  
     8  package web
     9  
    10  var urlTests = []struct {
    11  	url          string
    12  	filePath     string
    13  	canonicalURL string // If empty, assume equal to url.
    14  	wantErr      string
    15  }{
    16  	// Examples from RFC 8089:
    17  	{
    18  		url:      `file:///path/to/file`,
    19  		filePath: `/path/to/file`,
    20  	},
    21  	{
    22  		url:          `file:/path/to/file`,
    23  		filePath:     `/path/to/file`,
    24  		canonicalURL: `file:///path/to/file`,
    25  	},
    26  	{
    27  		url:          `file://localhost/path/to/file`,
    28  		filePath:     `/path/to/file`,
    29  		canonicalURL: `file:///path/to/file`,
    30  	},
    31  
    32  	// We reject non-local files.
    33  	{
    34  		url:     `file://host.example.com/path/to/file`,
    35  		wantErr: "file URL specifies non-local host",
    36  	},
    37  }
    38  

View as plain text