-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor(app): Standardize subdomain detection logic #9751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lonnieezell
merged 8 commits into
codeigniter4:4.7
from
lonnieezell:subdomain-detection
Oct 10, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
607a4d7
refactor(app): Standardize subdomain detection logic
lonnieezell b28ec8d
Update app/Config/Hostnames.php
lonnieezell 32220e7
Update tests/system/Helpers/URLHelper/MiscUrlTest.php
lonnieezell e969e0e
addressing review comments
lonnieezell 3d70779
cs fix
lonnieezell 46163a6
cs fix
lonnieezell acc1acf
cs fix
lonnieezell 22157a7
remove typo in docs ci-skip
lonnieezell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Config; | ||
|
||
class Hostnames | ||
{ | ||
// List of known two-part TLDs for subdomain extraction | ||
public const TWO_PART_TLDS = [ | ||
'co.uk', 'org.uk', 'gov.uk', 'ac.uk', 'sch.uk', 'ltd.uk', 'plc.uk', | ||
'com.au', 'net.au', 'org.au', 'edu.au', 'gov.au', 'asn.au', 'id.au', | ||
'co.jp', 'ac.jp', 'go.jp', 'or.jp', 'ne.jp', 'gr.jp', | ||
'co.nz', 'org.nz', 'govt.nz', 'ac.nz', 'net.nz', 'geek.nz', 'maori.nz', 'school.nz', | ||
'co.in', 'net.in', 'org.in', 'ind.in', 'ac.in', 'gov.in', 'res.in', | ||
'com.cn', 'net.cn', 'org.cn', 'gov.cn', 'edu.cn', | ||
'com.sg', 'net.sg', 'org.sg', 'gov.sg', 'edu.sg', 'per.sg', | ||
'co.za', 'org.za', 'gov.za', 'ac.za', 'net.za', | ||
'co.kr', 'or.kr', 'go.kr', 'ac.kr', 'ne.kr', 'pe.kr', | ||
'co.th', 'or.th', 'go.th', 'ac.th', 'net.th', 'in.th', | ||
'com.my', 'net.my', 'org.my', 'edu.my', 'gov.my', 'mil.my', 'name.my', | ||
'com.mx', 'org.mx', 'net.mx', 'edu.mx', 'gob.mx', | ||
'com.br', 'net.br', 'org.br', 'gov.br', 'edu.br', 'art.br', 'eng.br', | ||
'co.il', 'org.il', 'ac.il', 'gov.il', 'net.il', 'muni.il', | ||
'co.id', 'or.id', 'ac.id', 'go.id', 'net.id', 'web.id', 'my.id', | ||
'com.hk', 'edu.hk', 'gov.hk', 'idv.hk', 'net.hk', 'org.hk', | ||
'com.tw', 'net.tw', 'org.tw', 'edu.tw', 'gov.tw', 'idv.tw', | ||
'com.sa', 'net.sa', 'org.sa', 'gov.sa', 'edu.sa', 'sch.sa', 'med.sa', | ||
'co.ae', 'net.ae', 'org.ae', 'gov.ae', 'ac.ae', 'sch.ae', | ||
'com.tr', 'net.tr', 'org.tr', 'gov.tr', 'edu.tr', 'av.tr', 'gen.tr', | ||
'co.ke', 'or.ke', 'go.ke', 'ac.ke', 'sc.ke', 'me.ke', 'mobi.ke', 'info.ke', | ||
'com.ng', 'org.ng', 'gov.ng', 'edu.ng', 'net.ng', 'sch.ng', 'name.ng', | ||
'com.pk', 'net.pk', 'org.pk', 'gov.pk', 'edu.pk', 'fam.pk', | ||
'com.eg', 'edu.eg', 'gov.eg', 'org.eg', 'net.eg', | ||
'com.cy', 'net.cy', 'org.cy', 'gov.cy', 'ac.cy', | ||
'com.lk', 'org.lk', 'edu.lk', 'gov.lk', 'net.lk', 'int.lk', | ||
'com.bd', 'net.bd', 'org.bd', 'ac.bd', 'gov.bd', 'mil.bd', | ||
'com.ar', 'net.ar', 'org.ar', 'gov.ar', 'edu.ar', 'mil.ar', | ||
'gob.cl', 'com.pl', 'net.pl', 'org.pl', 'gov.pl', 'edu.pl', | ||
'co.ir', 'ac.ir', 'org.ir', 'id.ir', 'gov.ir', 'sch.ir', 'net.ir', | ||
]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
// Outputs "blog" | ||
echo parse_subdomain('blog.example.com'); | ||
|
||
// Outputs an empty string | ||
echo parse_subdomain('example.com'); | ||
echo parse_subdomain('example.co.uk'); | ||
|
||
// Outputs "shop" - correctly handles two-part TLDs | ||
echo parse_subdomain('shop.example.co.uk'); | ||
|
||
// Outputs "shop.old" | ||
echo parse_subdomain('shop.old.example.co.uk'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.