@@ -2000,31 +2000,31 @@ public static string GetValidatedURL(string url) {
20002000
20012001 int err = UrlApplyScheme ( url , validatedURL , ref validatedURLCapacity , URL_APPLYFlags . URL_APPLY_GUESSSCHEME ) ;
20022002
2003- if ( err == S_OK
2004- && validatedURLCapacity < validatedURL . Capacity ) {
2005- url = validatedURL . ToString ( ) ;
2006- } else {
2007- // second try the default scheme
2008- // we only do this to see if it returns S_FALSE, because
2009- // if so, we know there is already a scheme and don't add our own
2010- // we do not use the validated URL given by UrlApplyScheme here
2011- validatedURL . Clear ( ) ;
2012- validatedURLCapacity = ( uint ) validatedURL . Capacity ;
2013-
2014- err = UrlApplyScheme ( url , validatedURL , ref validatedURLCapacity , URL_APPLYFlags . URL_APPLY_DEFAULT ) ;
2015-
2016- // workaround: we always want to use HTTP, regardless of the default
2017- // (in case the default is HTTPS)
2018- if ( err != S_FALSE ) {
2019- // skip leading slashes for protocol-less URLs
2020- const string LEADING_SLASHES = "//" ;
2021-
2022- if ( url . StartsWith ( LEADING_SLASHES , StringComparison . Ordinal ) ) {
2023- url = url . Substring ( LEADING_SLASHES . Length ) ;
2024- }
2003+ if ( err == S_OK ) {
2004+ if ( validatedURLCapacity < validatedURL . Capacity ) {
2005+ return validatedURL . ToString ( ) ;
2006+ }
2007+ }
2008+
2009+ // second try the default scheme
2010+ // we only do this to see if it returns S_FALSE, because
2011+ // if so, we know there is already a scheme and don't add our own
2012+ // we do not use the validated URL given by UrlApplyScheme here
2013+ validatedURL . Clear ( ) ;
2014+ validatedURLCapacity = ( uint ) validatedURL . Capacity ;
2015+
2016+ err = UrlApplyScheme ( url , validatedURL , ref validatedURLCapacity , URL_APPLYFlags . URL_APPLY_DEFAULT ) ;
2017+
2018+ // workaround: we always want to use HTTP, regardless of the default
2019+ // (in case the default is HTTPS)
2020+ if ( err != S_FALSE ) {
2021+ // skip leading slashes for protocol-less URLs
2022+ const string LEADING_SLASHES = "//" ;
20252023
2026- url = URI_SCHEME_HTTP + "://" + url ;
2024+ if ( url . StartsWith ( LEADING_SLASHES , StringComparison . Ordinal ) ) {
2025+ url = url . Substring ( LEADING_SLASHES . Length ) ;
20272026 }
2027+ return URI_SCHEME_HTTP + "://" + url ;
20282028 }
20292029 return url ;
20302030 }
0 commit comments