Skip to content

Commit 0e3372e

Browse files
authored
IBX-10263: Allowed hyphens in HostText and UriText siteaccess matchers (#623)
1 parent 7bbaf69 commit 0e3372e

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/lib/MVC/Symfony/SiteAccess/Matcher/HostText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(array $siteAccessesConfiguration)
3232
$this->prefix = isset($siteAccessesConfiguration['prefix']) ? $siteAccessesConfiguration['prefix'] : '';
3333
$this->suffix = isset($siteAccessesConfiguration['suffix']) ? $siteAccessesConfiguration['suffix'] : '';
3434
parent::__construct(
35-
'^' . preg_quote($this->prefix, '@') . "(\w+)" . preg_quote($this->suffix, '@') . '$',
35+
'^' . preg_quote($this->prefix, '@') . "([\w-]+)" . preg_quote($this->suffix, '@') . '$',
3636
1
3737
);
3838
$this->siteAccessesConfiguration = $siteAccessesConfiguration;

src/lib/MVC/Symfony/SiteAccess/Matcher/URIText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $siteAccessesConfiguration)
3636
$this->suffix = isset($siteAccessesConfiguration['suffix']) ? $siteAccessesConfiguration['suffix'] : '';
3737

3838
parent::__construct(
39-
'^(/' . preg_quote($this->prefix, '@') . '(\w+)' . preg_quote($this->suffix, '@') . ')',
39+
'^(/' . preg_quote($this->prefix, '@') . '([\w-]+)' . preg_quote($this->suffix, '@') . ')',
4040
2
4141
);
4242
$this->siteAccessesConfiguration = $siteAccessesConfiguration;

tests/lib/MVC/Symfony/SiteAccess/RouterHostTextTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function matchProvider(): array
3333
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'default_sa'],
3434
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'default_sa'],
3535
[SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'default_sa'],
36+
[SimplifiedRequest::fromUrl('http://example.com/sa-with-hyphen'), 'sa-with-hyphen'],
3637

3738
[SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'first_sa'],
3839
[SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'first_sa'],
@@ -58,6 +59,7 @@ public function matchProvider(): array
5859
[SimplifiedRequest::fromUrl('http://www.example.com:82/'), 'example'],
5960
[SimplifiedRequest::fromUrl('https://www.example.com:83/'), 'example'],
6061
[SimplifiedRequest::fromUrl('http://www.example.com/foo/'), 'example'],
62+
[SimplifiedRequest::fromUrl('http://www.sa-with-hyphen.com'), 'sa-with-hyphen'],
6163

6264
[SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'second_sa'],
6365
[SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'second_sa'],
@@ -108,10 +110,12 @@ protected function createRouter(): Router
108110
'Map\\URI' => [
109111
'first_sa' => 'first_sa',
110112
'second_sa' => 'second_sa',
113+
'sa-with-hyphen' => 'sa-with-hyphen',
111114
],
112115
'Map\\Host' => [
113116
'first_sa' => 'first_sa',
114117
'first_siteaccess' => 'first_sa',
118+
'sa-with-hyphen' => 'sa-with-hyphen',
115119
],
116120
],
117121
$this->siteAccessProvider
@@ -131,6 +135,8 @@ public function getSiteAccessProviderSettings(): array
131135
new SiteAccessSetting('fifth_sa', true),
132136
new SiteAccessSetting('example', true),
133137
new SiteAccessSetting(self::DEFAULT_SA_NAME, true),
138+
new SiteAccessSetting('fifth_sa', true),
139+
new SiteAccessSetting('sa-with-hyphen', true),
134140
];
135141
}
136142
}

0 commit comments

Comments
 (0)