Skip to content

Commit

Permalink
Checking up on additional matching scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tit Petric authored and titpetric committed Sep 2, 2024
1 parent 34d6123 commit 74a7416
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gateway/api_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,18 @@ func (a APIDefinitionLoader) getPathSpecs(apiVersionDef apidef.VersionInfo, conf
}

func (a APIDefinitionLoader) generateRegex(stringSpec string, newSpec *URLSpec, specType URLStatus, conf config.Config) {
apiLangIDsRegex := regexp.MustCompile(`{([^}]*)}`)
asRegexStr := apiLangIDsRegex.ReplaceAllString(stringSpec, `([^/]*)`)
// old: convert regexp params to a path match equivalent
// apiLangIDsRegex := regexp.MustCompile(`{([^}]*)}`)
// asRegexStr := apiLangIDsRegex.ReplaceAllString(stringSpec, `([^/]*)`)

// new: use mux to provide a regex path
asRegexStr, _ := httputil.GetPathRegexp(stringSpec)

// Case insensitive match
if newSpec.IgnoreCase || conf.IgnoreEndpointCase {
asRegexStr = "(?i)" + asRegexStr
}

asRegex, _ := regexp.Compile(asRegexStr)
newSpec.Status = specType
newSpec.Spec = asRegex
Expand Down

0 comments on commit 74a7416

Please sign in to comment.