Skip to content

Commit eeed4bd

Browse files
authored
fix: invalid URI when an alias contains an underscore (#23)
1 parent 8f8f075 commit eeed4bd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Decoder/UriDecoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getUri(): string
4141
$uri = ltrim($this->uri, '/');
4242

4343
if (true === str_starts_with($uri, '_')) {
44-
$domainAlias = str_replace('_', '', explode('/', $uri)[0]);
44+
$domainAlias = trim(explode('/', $uri)[0], '_');
4545
$domain = $this->domainsAliases[$domainAlias] ?? '';
4646
$uri = str_replace("_{$domainAlias}_", $domain, $uri);
4747
}

tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
class TestCase extends BaseTestCase
2424
{
2525
protected const string TEST_BASE_URI = 'https://example.com/image.jpg';
26-
protected const string TEST_BASE_URI_ALIAS = '_e_/image.jpg';
26+
protected const string TEST_BASE_URI_ALIAS = '_ex_ample_/image.jpg';
2727
protected const string TEST_WATERMARK_URL = 'https://example.com/watermark.jpg';
2828
protected const string TEST_DOMAIN = 'example.com';
29-
protected const string TEST_DOMAIN_ALIAS = 'e';
29+
protected const string TEST_DOMAIN_ALIAS = 'ex_ample';
3030
protected const string TEST_FILENAME = 'image.jpg';
3131
protected const string TEST_FILENAME_MD5 = '18867d45576d8283d6fabb82406789c8.jpg';
3232
protected const string TEST_EXTENSION = 'jpg';

0 commit comments

Comments
 (0)