Skip to content

Commit 0159345

Browse files
committed
Support links without options
1 parent cd18759 commit 0159345

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/UrlBuilder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ public function url(string $src, ?string $extension = null): string
9696
{
9797
$format = $extension ? new ImageFormat($extension) : null;
9898

99-
$opt = implode('/', $this->options);
100-
$path = sprintf('/%s/%s', $opt, $this->source($src, $format));
99+
$path = implode('/', [
100+
'',
101+
...$this->options,
102+
$this->source($src, $format),
103+
]);
101104

102105
return sprintf('/%s%s', $this->signature($path), $path);
103106
}

tests/UrlBuilderTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ public function signedData(): array
114114
'plain' => '/0c-LLep4C-7PBda91FC_d5nEJpyyGH1qzNuifVFG32k/w:300/h:400/rt:fit/plain/http://example.com/image.jpg',
115115
'encoded' => '/0pEYejprWvTcn8ZeJzbHU91zCGFpWjOHMaWhY57aISs/w:300/h:400/rt:fit/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw.jpg',
116116
],
117+
[
118+
'src' => 'local:///logos/evil_martians.png',
119+
'format' => 'jpg',
120+
'options' => [],
121+
'plain' => '/ULisISQ1rO57bD0OFBi0sQQjngiG5hLM1G8lZNrmFnU/plain/local:///logos/evil_martians.png@jpg',
122+
'encoded' => '/UXBqIs6HQ2FlcNLEcx5V0OGfuujgcBZynk0r500gf7A/bG9jYWw6Ly8vbG9n/b3MvZXZpbF9tYXJ0/aWFucy5wbmc.jpg',
123+
],
117124
];
118125
}
119126

0 commit comments

Comments
 (0)