tags:

views:

43

answers:

4

The url of our search page is build like this:
http://www.example.com/results/name/John/city/Miami/gender/Male This would display every male named John in Miami.

When one of the filters is left empty, the url would be something like this:
http://www.example.com/results/name/John/city//gender/Male
So there are two slashes in the url.

Outlook doesn't seem to like this. When you click on the second url, it removes one of the two slashes. This leaves the url like this:
http://www.example.com/results/name/John/city/gender/Male
Persons names John in the city 'gender'..

What would be the best way to fix this problem?

A: 

The standard is to collapse the two slashes into one, so there is no way to prevent this from happening. It might be a good idea to put something between those slashes to indicate to your search page that that field is blank.

Alternatively, you could change the search page to use a query string such as this:

http://www.example.com/results?name=John&city=&gender=Male

Aaron
A: 

Try to replace (one of) the slashes with ASCII code 2F (decimal 47).

Peter Schuetze
A: 

If you must use slashes, consider fixing this on the server side. Create a list of keywords (city|results|...) and, if a slash is followed by one of the keywords, treat it as an empty entry. (edited) Double slashes should not be treated as one, but as you found out, some applications "fix" this.

An alternative and standard way of fixing this is using a placeholder, normally a dot, because it has no special meaning:

http://example.com/results/name/./city/amsterdam

Abel
I don't like the idea of putting something in it as an empty value that *could* be a valid input.
Robin
I understand. You should choose whether you want to allow buggy URLs (with collapsed slashes) with wrong results, or whether you want to fix it. But be alarmed: once you start adjusting your application to adapt to every other buggy program, there may be no end in sight...
Abel
Peter Schuetze
+2  A: 

This is a bug in Microsoft Office.

URLs with two consecutive slashes are allowed by RFC 2396, but they're not commonly used. As the RFC says (extract from Appendix A):

abs_path      = "/"  path_segments
path_segments = segment *( "/" segment )
segment       = *pchar *( ";" param )

Note that segment is defined as containing ZERO OR MORE characters. (You might argue that this is a spec bug, and it shouldn't be allowed... but it is)

As you've discovered, Microsoft Office will "fix" URLs containing double slashes. This is apparently a deliberate feature for "cleanliness and consistency". There is no way to override or disable it. Source.

So, as other people have suggested, you're probably going to have to change the way the server formats URLs.

user9876
+1 for better explanation of the standard. Note that the original RFC 1738 has the same specification when it comes to paths.
Abel