Skip to content

Commit

Permalink
Minor templating updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ameenmaali committed Mar 22, 2020
1 parent c848f60 commit 6457edc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func expandTemplatedValues(ruleInjection string, u *url.URL) string {
re := regexp.MustCompile(`\[\[([^\[\]]*)\]\]`)

templateMatches := re.FindAllString(ruleInjection, -1)
// Although this loop isn't necessary, keeping it here to remove "nexted" templates in certain scenarios
// and for future refactoring to a better system
for _, match := range templateMatches {
if strings.ToLower(match) == "[[fullurl]]" {
ruleInjection = strings.ReplaceAll(ruleInjection, match, url.QueryEscape(u.String()))
Expand All @@ -178,7 +180,7 @@ func expandTemplatedValues(ruleInjection string, u *url.URL) string {
}

if strings.ToLower(match) == "[[path]]" {
ruleInjection = strings.ReplaceAll(ruleInjection, match, u.Path)
ruleInjection = strings.ReplaceAll(ruleInjection, match, url.QueryEscape(u.Path))
}

}
Expand Down

0 comments on commit 6457edc

Please sign in to comment.