none
Uri (.net 3.5) class deforming url by removing '.' (dot) RRS feed

  • Question

  • I have a url which has a folder ( "o-1386-sanju.")  with a trailing '.' (dot) in it. When i make a uri with it, the uri removes the '.' from it. I tried to escape the dot with %2E but it is still removed. Any suggestions on how i can make a uri of this url. I am using .net 3.5

    Output:

    String uri              = "https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju./9ef15109-4292-481c_o1386_e0_w.png"
    new Uri(uri).ToString() = "https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju/9ef15109-4292-481c_o1386_e0_w.png"
    
    String uri              = "https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju%2E/9ef15109-4292-481c_o1386_e0_w.png"
    new Uri(uri).ToString() = "https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju/9ef15109-4292-481c_o1386_e0_w.png"

    Code used to generate above output:

    String[] urls = new String[]{
    	"https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju./9ef15109-4292-481c_o1386_e0_w.png",
    	"https://pixfirst-fr.s3.amazonaws.com/photos/o-1386-sanju%2E/9ef15109-4292-481c_o1386_e0_w.png"
    };
    
    foreach (String url in urls)
    {
    	Uri uri = new Uri(url);
    
    	Console.WriteLine("String uri              = \"{0}\"\nnew Uri(uri).ToString() = \"{1}\"\n", url, uri.ToString());
    }


    • Edited by Mithun Dhali Thursday, May 29, 2014 4:54 PM Updated subject
    Thursday, May 29, 2014 4:49 PM

Answers