Skip to content
This repository was archived by the owner on Aug 8, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Classes/Utility/GeneralUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,21 @@ public static function fullUrl($url, $domain = null)
if ($url === '/') {
$url = '';
}

// remove first /
if (strpos($url, '/') === 0) {
$url = substr($url, 1);
}


if ($domain !== null) {
// specified domain
$url = 'http://' . $domain . '/' . $url;
if(!preg_match('/^https?:\/\//i', $domain)) {
$domain = 'http://' . $domain;
Copy link
Member

@thomaszbz thomaszbz Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about https support? Regex expression allows https, but $domain = forgets that.

Btw., is this an old (separate) issue, which always existed (eventually add a new/separate github issue?)?

Copy link
Author

@Teddytrombone Teddytrombone Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we have to make some assumptions. If the passed domain has a scheme, everything is ok, so no scheme is prepended. If there is no scheme - so the regex doesn't match - I think we can't reliably guess the correct scheme at this code line (because in fact, the domain could be any domain, which could have https support or not), so the best is to stick with http ;-)

Instead of the regex a parse_url call could be used to check, if there is a scheme. Or we could make the regex more general ('/[a-z]+:\/\//i').

Copy link
Author

@Teddytrombone Teddytrombone Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user of this method really wants to specify the scheme, it could be done with the $domain parameter. Maybe it's more clear to rename the parameter from $domain to something like $baseUrlOverride

}
$domain = rtrim($domain, '/').'/';
} else {
// domain from env
$url = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url;
if (strpos($url, '/') === 0) {
$domain = Typo3GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST');
} else {
$domain = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
}
}

$url = $domain . $url;
}

// Fix url stuff
Expand Down