Update index.php

This commit is contained in:
Namhyeon Go 2019-05-24 01:58:50 +09:00 committed by GitHub
parent 671aa580ba
commit 2445f8662a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,8 +27,16 @@ if(CORS_DOMAINS !== false) {
if(!in_array("*", $domains)) {
foreach($domains as $domain) {
if(!empty($domain)) {
$origins[] = sprintf("https://%s", $domain);
$origins[] = sprintf("http://%s", $domain);
if(substr($domain, 0, 2) == "*.") { // support wildcard
$needle = substr($domain, 1);
$length = strlen($needle);
if(substr($_origin, -$length) === $needle) {
$origins[] = $_origin;
}
} else {
$origins[] = sprintf("https://%s", $domain);
$origins[] = sprintf("http://%s", $domain);
}
}
}
if(count($origins) > 0) {