Add scheme to URL if needed

后端 未结 5 1912
耶瑟儿~
耶瑟儿~ 2020-12-08 08:49

To create a Uri from a string you can do this:

Uri u = new Uri(\"example.com\");

But the problem is if the string (like the one above) does

5条回答
  •  春和景丽
    2020-12-08 09:52

    My solution was for protocall-less urls to make sure they have protocal was regex :

    Regex.Replace(s, @"^\/\/", "http://");
    

提交回复
热议问题