@@ -604,7 +604,7 @@ bool URL::isWellFormed() const
604604 if (URLHelpers::isIPv6Address (url, domainStart))
605605 {
606606 if (URLHelpers::findIPv6End (url, domainStart) < 0 )
607- return false ; // No closing bracket
607+ return false ;
608608 }
609609
610610 // Extract and validate port if present
@@ -640,48 +640,39 @@ bool URL::isWellFormed() const
640640
641641 if (! isIPv4 && ! isIPv6)
642642 {
643- #if YUP_WINDOWS
644- // Special case for Windows file URLs with drive letters (e.g., "C:")
645- if (scheme == " file" && domain.length () == 2 && CharacterFunctions::isLetter (domain[0 ]) && domain[1 ] == ' :' )
646- {
647- // Valid Windows drive letter
648- }
649- else
650- #endif
643+ // Validate as hostname: check for valid hostname characters
644+ bool lastWasDot = false ;
645+ bool lastWasHyphen = false ;
646+
647+ for (int i = 0 ; i < domain.length (); ++i)
651648 {
652- // Validate as hostname
653- // Check for valid hostname characters
654- bool lastWasDot = false ;
655- bool lastWasHyphen = false ;
649+ auto ch = domain[i];
656650
657- for ( int i = 0 ; i < domain. length (); ++i )
651+ if (ch == ' . ' )
658652 {
659- auto ch = domain[i];
660-
661- if (ch == ' .' )
662- {
663- if (i == 0 || i == domain.length () - 1 || lastWasDot || lastWasHyphen)
664- return false ;
665- lastWasDot = true ;
666- lastWasHyphen = false ;
667- }
668- else if (ch == ' -' )
669- {
670- if (i == 0 || i == domain.length () - 1 || lastWasDot)
671- return false ;
672- lastWasHyphen = true ;
673- lastWasDot = false ;
674- }
675- else if (CharacterFunctions::isLetterOrDigit (ch))
676- {
677- lastWasDot = false ;
678- lastWasHyphen = false ;
679- }
680- else
681- {
682- // Invalid character in hostname
653+ if (i == 0 || i == domain.length () - 1 || lastWasDot || lastWasHyphen)
683654 return false ;
684- }
655+
656+ lastWasDot = true ;
657+ lastWasHyphen = false ;
658+ }
659+ else if (ch == ' -' )
660+ {
661+ if (i == 0 || i == domain.length () - 1 || lastWasDot)
662+ return false ;
663+
664+ lastWasHyphen = true ;
665+ lastWasDot = false ;
666+ }
667+ else if (CharacterFunctions::isLetterOrDigit (ch))
668+ {
669+ lastWasDot = false ;
670+ lastWasHyphen = false ;
671+ }
672+ else
673+ {
674+ // Invalid character in hostname
675+ return false ;
685676 }
686677 }
687678 }
@@ -964,8 +955,7 @@ bool URL::isProbablyAnEmailAddress (const String& possibleEmailAddress)
964955
965956String URL::getDomainInternal (bool ignorePort) const
966957{
967- // Special handling for file URLs with three slashes (file:///)
968- // These should have empty domain
958+ // Special handling for file URLs with three slashes (file:///) should have empty domain
969959 if (getScheme () == " file" && url.substring (0 , 8 ) == " file:///" )
970960 return String ();
971961
@@ -1111,6 +1101,7 @@ class iOSFileStreamWrapper final : public Stream
11111101 }
11121102};
11131103#endif
1104+
11141105// ==============================================================================
11151106template <typename Member, typename Item>
11161107static URL::InputStreamOptions with (URL::InputStreamOptions options, Member&& member, Item&& item)
0 commit comments