@@ -383,25 +383,30 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
383383 } while (TRUE );
384384
385385
386- if ($ this ->type !== self ::HOST ) {
386+ if ($ this ->type === self ::HOST ) {
387+ $ host = $ refUrl ->getHost ();
388+ $ parts = ip2long ($ host ) ? [$ host ] : array_reverse (explode ('. ' , $ host ));
389+ $ url = strtr ($ url , [
390+ '/%basePath%/ ' => $ refUrl ->getBasePath (),
391+ '%tld% ' => $ parts [0 ],
392+ '%domain% ' => isset ($ parts [1 ]) ? "$ parts [1 ]. $ parts [0 ]" : $ parts [0 ],
393+ '%sld% ' => isset ($ parts [1 ]) ? $ parts [1 ] : '' ,
394+ ]);
395+ if ($ this ->flags & self ::SECURED ) {
396+ $ url = 'https: ' . $ url ;
397+ } elseif (strncmp ($ url , "// $ host/ " , strlen ($ host ) + 3 ) === 0 ) {
398+ $ url = $ refUrl ->getScheme () . ': ' . $ url ;
399+ } else {
400+ $ url = 'http: ' . $ url ;
401+ }
402+ } else {
387403 if ($ this ->lastRefUrl !== $ refUrl ) {
388- $ scheme = ($ this ->flags & self ::SECURED ? 'https:// ' : ' http :// ' );
404+ $ scheme = ($ this ->flags & self ::SECURED ? 'https:// ' : $ refUrl -> getScheme () . ' :// ' );
389405 $ basePath = ($ this ->type === self ::RELATIVE ? $ refUrl ->getBasePath () : '' );
390406 $ this ->lastBaseUrl = $ scheme . $ refUrl ->getAuthority () . $ basePath ;
391407 $ this ->lastRefUrl = $ refUrl ;
392408 }
393409 $ url = $ this ->lastBaseUrl . $ url ;
394-
395- } else {
396- $ host = $ refUrl ->getHost ();
397- $ host = ip2long ($ host ) ? [$ host ] : array_reverse (explode ('. ' , $ host ));
398- $ url = strtr ($ url , [
399- '/%basePath%/ ' => $ refUrl ->getBasePath (),
400- '%tld% ' => $ host [0 ],
401- '%domain% ' => isset ($ host [1 ]) ? "$ host [1 ]. $ host [0 ]" : $ host [0 ],
402- '%sld% ' => isset ($ host [1 ]) ? $ host [1 ] : '' ,
403- ]);
404- $ url = ($ this ->flags & self ::SECURED ? 'https: ' : 'http: ' ) . $ url ;
405410 }
406411
407412 if (strpos ($ url , '// ' , 7 ) !== FALSE ) {
0 commit comments