@@ -150,12 +150,13 @@ public function match(Nette\Http\IRequest $httpRequest)
150150if ($ this ->type === self ::HOST ) {
151151$ host = $ url ->getHost ();
152152$ path = '// ' . $ host . $ url ->getPath ();
153- $ host = ip2long ($ host ) ? array ($ host ) : array_reverse (explode ('. ' , $ host ));
153+ $ parts = ip2long ($ host ) ? array ($ host ) : array_reverse (explode ('. ' , $ host ));
154154$ re = strtr ($ re , array (
155155'/%basePath%/ ' => preg_quote ($ url ->getBasePath (), '# ' ),
156- '%tld% ' => preg_quote ($ host [0 ], '# ' ),
157- '%domain% ' => preg_quote (isset ($ host [1 ]) ? "$ host [1 ]. $ host [0 ]" : $ host [0 ], '# ' ),
158- '%sld% ' => preg_quote (isset ($ host [1 ]) ? $ host [1 ] : '' , '# ' ),
156+ '%tld% ' => preg_quote ($ parts [0 ], '# ' ),
157+ '%domain% ' => preg_quote (isset ($ parts [1 ]) ? "$ parts [1 ]. $ parts [0 ]" : $ parts [0 ], '# ' ),
158+ '%sld% ' => preg_quote (isset ($ parts [1 ]) ? $ parts [1 ] : '' , '# ' ),
159+ '%host% ' => preg_quote ($ host , '# ' ),
159160));
160161
161162} elseif ($ this ->type === self ::RELATIVE ) {
@@ -381,25 +382,25 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
381382} while (TRUE );
382383
383384
384- if ($ this ->type !== self ::HOST ) {
385+ if ($ this ->type === self ::HOST ) {
386+ $ host = $ refUrl ->getHost ();
387+ $ parts = ip2long ($ host ) ? array ($ host ) : array_reverse (explode ('. ' , $ host ));
388+ $ url = strtr ($ url , array (
389+ '/%basePath%/ ' => $ refUrl ->getBasePath (),
390+ '%tld% ' => $ parts [0 ],
391+ '%domain% ' => isset ($ parts [1 ]) ? "$ parts [1 ]. $ parts [0 ]" : $ parts [0 ],
392+ '%sld% ' => isset ($ parts [1 ]) ? $ parts [1 ] : '' ,
393+ '%host% ' => $ host ,
394+ ));
395+ $ url = ($ this ->flags & self ::SECURED ? 'https: ' : 'http: ' ) . $ url ;
396+ } else {
385397if ($ this ->lastRefUrl !== $ refUrl ) {
386398$ scheme = ($ this ->flags & self ::SECURED ? 'https:// ' : 'http:// ' );
387399$ basePath = ($ this ->type === self ::RELATIVE ? $ refUrl ->getBasePath () : '' );
388400$ this ->lastBaseUrl = $ scheme . $ refUrl ->getAuthority () . $ basePath ;
389401$ this ->lastRefUrl = $ refUrl ;
390402}
391403$ url = $ this ->lastBaseUrl . $ url ;
392-
393- } else {
394- $ host = $ refUrl ->getHost ();
395- $ host = ip2long ($ host ) ? array ($ host ) : array_reverse (explode ('. ' , $ host ));
396- $ url = strtr ($ url , array (
397- '/%basePath%/ ' => $ refUrl ->getBasePath (),
398- '%tld% ' => $ host [0 ],
399- '%domain% ' => isset ($ host [1 ]) ? "$ host [1 ]. $ host [0 ]" : $ host [0 ],
400- '%sld% ' => isset ($ host [1 ]) ? $ host [1 ] : '' ,
401- ));
402- $ url = ($ this ->flags & self ::SECURED ? 'https: ' : 'http: ' ) . $ url ;
403404}
404405
405406if (strpos ($ url , '// ' , 7 ) !== FALSE ) {
0 commit comments