Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for firstSegment (0.1 sec)

  1. src/net/http/routing_tree.go

    		}
    		return c, matches
    	}
    	return nil, nil
    }
    
    // firstSegment splits path into its first segment, and the rest.
    // The path must begin with "/".
    // If path consists of only a slash, firstSegment returns ("/", "").
    // The segment is returned unescaped, if possible.
    func firstSegment(path string) (seg, rest string) {
    	if path == "/" {
    		return "/", ""
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 30 15:43:24 UTC 2024
    - 7.5K bytes
    - Viewed (0)
  2. src/net/http/routing_tree_test.go

    		{"/", []string{"/"}},
    		{"/a/%62/c", []string{"a", "b", "c"}},
    		{"/a%2Fb%2fc", []string{"a/b/c"}},
    	} {
    		var got []string
    		rest := test.in
    		for len(rest) > 0 {
    			var seg string
    			seg, rest = firstSegment(rest)
    			got = append(got, seg)
    		}
    		if !slices.Equal(got, test.want) {
    			t.Errorf("%q: got %v, want %v", test.in, got, test.want)
    		}
    	}
    }
    
    // TODO: test host and method
    var testTree *routingNode
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 30 15:43:24 UTC 2024
    - 7K bytes
    - Viewed (0)
Back to top