This repository was archived by the owner on Sep 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1515
1616use Bakame \Aide \Uri \UrlValidationErrorCollector ;
1717use Exception ;
18- use League \Uri \UriString ;
1918use ReflectionClass ;
2019use Rowbot \Idna \Idna ;
20+ use Rowbot \URL \Component \Host \StringHost ;
2121use Rowbot \URL \URL as WhatWgURL ;
22+ use Rowbot \URL \URLRecord ;
2223use SensitiveParameter ;
2324use Uri \UriComparisonMode ;
2425
@@ -294,12 +295,19 @@ public function toUnicodeString(): string
294295 }
295296
296297 $ unicodeHost = $ this ->getUnicodeHost ();
297- $ this ->urlUnicodeString = $ this ->getAsciiHost () === $ unicodeHost
298- ? $ this ->url ->href
299- : UriString::build ([
300- ...UriString::parse ($ this ->url ->href ),
301- ...['host ' => $ unicodeHost ],
302- ]);
298+ if (null === $ unicodeHost || $ this ->getAsciiHost () === $ unicodeHost ) {
299+ $ this ->urlUnicodeString = $ this ->url ->href ;
300+
301+ return $ this ->urlUnicodeString ;
302+ }
303+
304+ //We use the URLRecord to stay fully compliant with the WHATAG specification
305+ //We are forced tu use reflection as we can not access the URLRecord directly
306+ $ refl = new ReflectionClass (WhatWgURL::class);
307+ /** @var URLRecord $urlRecord */
308+ $ urlRecord = $ refl ->getProperty ('url ' )->getValue ($ this ->url );
309+ $ urlRecord ->host = new StringHost ($ unicodeHost );
310+ $ this ->urlUnicodeString = $ urlRecord ->serializeURL ();
303311
304312 return $ this ->urlUnicodeString ;
305313 }
You can’t perform that action at this time.
0 commit comments