Files
hadrian/proxychain/requestmodifiers/modify_path_with_regex.go
2023-12-04 19:55:50 -06:00

19 lines
514 B
Go

package requestmodifiers
import (
"fmt"
"ladder/proxychain"
"regexp"
)
func ModifyPathWithRegex(matchRegex string, replacement string) proxychain.RequestModification {
match, err := regexp.Compile(matchRegex)
return func(px *proxychain.ProxyChain) error {
if err != nil {
return fmt.Errorf("RequestModification :: ModifyPathWithRegex error => invalid match regex: %s - %s", matchRegex, err.Error())
}
px.Request.URL.Path = match.ReplaceAllString(px.Request.URL.Path, replacement)
return nil
}
}