Skip to content

Commit

Permalink
Renaming 'nocase' to 'iprefix'
Browse files Browse the repository at this point in the history
  • Loading branch information
herbrandson committed Sep 20, 2018
1 parent b77f9d9 commit 53b26b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
return nil, fmt.Errorf("invalid proxy.strategy: %s", cfg.Proxy.Strategy)
}

if cfg.Proxy.Matcher != "prefix" && cfg.Proxy.Matcher != "glob" && cfg.Proxy.Matcher != "nocase" {
if cfg.Proxy.Matcher != "prefix" && cfg.Proxy.Matcher != "glob" && cfg.Proxy.Matcher != "iprefix" {
return nil, fmt.Errorf("invalid proxy.matcher: %s", cfg.Proxy.Matcher)
}

Expand Down
4 changes: 2 additions & 2 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ func TestLoad(t *testing.T) {
},
},
{
args: []string{"-proxy.matcher", "nocase"},
args: []string{"-proxy.matcher", "iprefix"},
cfg: func(cfg *Config) *Config {
cfg.Proxy.Matcher = "nocase"
cfg.Proxy.Matcher = "iprefix"
return cfg
},
},
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ref/proxy.matcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function.
For example, `/foo*` matches `/foo`, `/fool` and `/fools`. Also, `/foo/*/bar`
matches `/foo/x/bar`.

`nocase` matching is similar to `prefix`, except it uses a case insensitive comparison
`iprefix` matching is similar to `prefix`, except it uses a case insensitive comparison

The default is

Expand Down
2 changes: 1 addition & 1 deletion fabio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
#
# prefix: prefix matching
# glob: glob matching
# nocase: matches using a case insensitive test
# iprefix: case-insensitive prefix matching
#
# The default is
#
Expand Down
10 changes: 5 additions & 5 deletions route/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ type matcher func(uri string, r *Route) bool
// Matcher contains the available matcher functions.
// Update config/load.go#load after updating.
var Matcher = map[string]matcher{
"prefix": prefixMatcher,
"glob": globMatcher,
"nocase": noCaseMatcher,
"prefix": prefixMatcher,
"glob": globMatcher,
"iprefix": iPrefixMatcher,
}

// prefixMatcher matches path to the routes' path.
Expand All @@ -25,8 +25,8 @@ func globMatcher(uri string, r *Route) bool {
return r.Glob.Match(uri)
}

// noCase matches path to the routes' path ignoring case
func noCaseMatcher(uri string, r *Route) bool {
// iPrefixMatcher matches path to the routes' path ignoring case
func iPrefixMatcher(uri string, r *Route) bool {
lowerURI := strings.ToLower(uri)
lowerPath := strings.ToLower(r.Path)
return strings.HasPrefix(lowerURI, lowerPath)
Expand Down
4 changes: 2 additions & 2 deletions route/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestGlobMatcher(t *testing.T) {
}
}

func TestNoCaseMatcher(t *testing.T) {
func TestIPrefixMatcher(t *testing.T) {
tests := []struct {
uri string
matches bool
Expand All @@ -75,7 +75,7 @@ func TestNoCaseMatcher(t *testing.T) {

for _, tt := range tests {
t.Run(tt.uri, func(t *testing.T) {
if got, want := noCaseMatcher(tt.uri, tt.route), tt.matches; got != want {
if got, want := iPrefixMatcher(tt.uri, tt.route), tt.matches; got != want {
t.Fatalf("got %v want %v", got, want)
}
})
Expand Down

0 comments on commit 53b26b2

Please sign in to comment.