Skip to content

Commit b1efd60

Browse files
authored
Always build encoded url with a file extension if it is passed explicitly. (#5)
1 parent 5ee9dee commit b1efd60

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/UrlBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function source(string $src, ?ImageFormat $format): string
123123
}
124124

125125
$extension = null;
126-
if ($format && !$format->isEquals($this->extension($src))) {
126+
if ($format && ($this->encoded || !$format->isEquals($this->extension($src)))) {
127127
$extension = $format->value();
128128
}
129129

tests/UrlBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function signedData(): array
112112
new ResizingType('fit'),
113113
],
114114
'plain' => '/0c-LLep4C-7PBda91FC_d5nEJpyyGH1qzNuifVFG32k/w:300/h:400/rt:fit/plain/http://example.com/image.jpg',
115-
'encoded' => '/hWXG9tmSiWjjyjTZZtLo5Ty-Zs4WNzd76pvvjpCD28c/w:300/h:400/rt:fit/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw',
115+
'encoded' => '/0pEYejprWvTcn8ZeJzbHU91zCGFpWjOHMaWhY57aISs/w:300/h:400/rt:fit/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw.jpg',
116116
],
117117
];
118118
}
@@ -159,7 +159,7 @@ public function unsignedData(): array
159159
new ResizingType('fit'),
160160
],
161161
'plain' => '/insecure/w:300/h:400/rt:fit/plain/http://example.com/image.jpg',
162-
'encoded' => '/insecure/w:300/h:400/rt:fit/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw',
162+
'encoded' => '/insecure/w:300/h:400/rt:fit/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw.jpg',
163163
],
164164
];
165165
}

0 commit comments

Comments
 (0)