You've already forked imgproxy
mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-12-03 23:19:17 +02:00
Try to fix path if signature is invalid
This commit is contained in:
22
fix_path.go
Normal file
22
fix_path.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var fixPathRe = regexp.MustCompile(`/plain/(\S+)\:/([^/])`)
|
||||
|
||||
func fixPath(path string) string {
|
||||
for _, match := range fixPathRe.FindAllStringSubmatch(path, -1) {
|
||||
repl := fmt.Sprintf("/plain/%s://", match[1])
|
||||
if match[1] == "local" {
|
||||
repl += "/"
|
||||
}
|
||||
repl += match[2]
|
||||
path = strings.Replace(path, match[0], repl, 1)
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
Reference in New Issue
Block a user