mirror of
https://github.com/imgproxy/imgproxy.git
synced 2026-06-18 17:43:40 +02:00
Do not add base URL if the image URL already contains it
This commit is contained in:
@@ -334,7 +334,7 @@ imgproxy can send logs to syslog, but this feature is disabled by default. To en
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
* `IMGPROXY_BASE_URL`: base URL prefix that will be added to every requested image URL. For example, if the base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the source image from `http://example.com/images/path/to/image.png`. Default: blank.
|
||||
* `IMGPROXY_BASE_URL`: base URL prefix that will be added to every requested image URL. For example, if the base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the source image from `http://example.com/images/path/to/image.png`. If the image URL already contains the prefix, it won't be added. Default: blank.
|
||||
* `IMGPROXY_USE_LINEAR_COLORSPACE`: when `true`, imgproxy will process images in linear colorspace. This will slow down processing. Note that images won't be fully processed in linear colorspace while shrink-on-load is enabled (see below).
|
||||
* `IMGPROXY_DISABLE_SHRINK_ON_LOAD`: when `true`, disables shrink-on-load for JPEG and WebP. Allows to process the whole image in linear colorspace but dramatically slows down resizing and increases memory usage when working with large images.
|
||||
* `IMGPROXY_STRIP_METADATA`: when `true`, imgproxy will strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true`.
|
||||
|
||||
+10
-6
@@ -304,6 +304,14 @@ func colorFromHex(hexcolor string) (rgbColor, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func addBaseURL(u string) string {
|
||||
if len(conf.BaseURL) == 0 || strings.HasPrefix(u, conf.BaseURL) {
|
||||
return u
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%s", conf.BaseURL, u)
|
||||
}
|
||||
|
||||
func decodeBase64URL(parts []string) (string, string, error) {
|
||||
var format string
|
||||
|
||||
@@ -327,9 +335,7 @@ func decodeBase64URL(parts []string) (string, string, error) {
|
||||
return "", "", fmt.Errorf("Invalid url encoding: %s", encoded)
|
||||
}
|
||||
|
||||
fullURL := fmt.Sprintf("%s%s", conf.BaseURL, string(imageURL))
|
||||
|
||||
return fullURL, format, nil
|
||||
return addBaseURL(string(imageURL)), format, nil
|
||||
}
|
||||
|
||||
func decodePlainURL(parts []string) (string, string, error) {
|
||||
@@ -355,9 +361,7 @@ func decodePlainURL(parts []string) (string, string, error) {
|
||||
return "", "", fmt.Errorf("Invalid url encoding: %s", encoded)
|
||||
}
|
||||
|
||||
fullURL := fmt.Sprintf("%s%s", conf.BaseURL, unescaped)
|
||||
|
||||
return fullURL, format, nil
|
||||
return addBaseURL(unescaped), format, nil
|
||||
}
|
||||
|
||||
func decodeURL(parts []string) (string, string, error) {
|
||||
|
||||
Reference in New Issue
Block a user