mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #398 from creative-commoners/pulls/2.1/ignore-domain-port
FIX Ignore ports when matching domain for subsite
This commit is contained in:
commit
810ee63ea6
@ -257,6 +257,10 @@ class Subsite extends DataObject
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
|
||||
// Remove ports, we aren't concerned with them in terms of detecting subsites via domains
|
||||
$hostParts = explode(':', $host);
|
||||
$host = reset($hostParts);
|
||||
|
||||
$matchingDomains = null;
|
||||
$cacheKey = null;
|
||||
if ($host) {
|
||||
|
@ -191,12 +191,23 @@ class SubsiteTest extends BaseSubsiteTest
|
||||
Subsite::getSubsiteIDForDomain('example.org'),
|
||||
'Exact matches without strict checking when not using www prefix'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite1->ID,
|
||||
Subsite::getSubsiteIDForDomain('example.org:1123'),
|
||||
'Exact matches without strict checking when not using www prefix and ignores port'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite1->ID,
|
||||
Subsite::getSubsiteIDForDomain('www.example.org'),
|
||||
'Matches without strict checking when using www prefix, '
|
||||
.'still matching first domain regardless of www prefix (falling back to subsite primary key ordering)'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite1->ID,
|
||||
Subsite::getSubsiteIDForDomain('www.example.org:9923'),
|
||||
'Matches without strict checking when using www prefix, '
|
||||
.'still matching first domain without prefix (falling back to primary key ordering and ignoring port)'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite1->ID,
|
||||
Subsite::getSubsiteIDForDomain('www.example.com'),
|
||||
@ -215,6 +226,11 @@ class SubsiteTest extends BaseSubsiteTest
|
||||
Subsite::getSubsiteIDForDomain('example.org'),
|
||||
'Matches with strict checking when not using www prefix'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite1->ID,
|
||||
Subsite::getSubsiteIDForDomain('example.org:123'),
|
||||
'Matches with strict checking when not using www prefix and ignores port'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$subsite2->ID, // not 1
|
||||
Subsite::getSubsiteIDForDomain('www.example.org'),
|
||||
|
Loading…
Reference in New Issue
Block a user