1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-18 16:31:44 +02:00
imgproxy/fix_path.go
2022-09-15 22:12:16 +06:00

23 lines
399 B
Go

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
}