views:

52

answers:

1

I am using the URL for an HTTP resource as unique identifiers for the resources (surprise).

These are all different:

http://localhost/Docs/SomeDocument?group=33&checksafety=true
http://localhost/Docs/SomeDocument?group=11&checksafety=true
http://localhost/Docs/SomeDocument?group=11&checksafety=false

However, I have a third query parameter that should not differentiate resources (on the server side, it pulls the same data from the database).

These are the same (the group and checksafety parameters are the same):

http://localhost/Docs/SomeDocument?group=11&checksafety=false&rendergroup=A
http://localhost/Docs/SomeDocument?group=11&checksafety=false&rendergroup=B
http://localhost/Docs/SomeDocument?rendergroup=C&group=11&checksafety=false

Is a regex appropriate here?

Is there a better way?

I am using C#, .NET 3.5 and ASP.NET.

A: 

You could split to get the querystring, then split to get each group, see if all of them have the same number of groups (by group I mean "variable=value"). Analyse each group individually and eliminate the ones that doesn't care.

Then, it is easier to analyse. Here are some ideas

  • put each group into a List and order it (and then iterate to see if they are the same
  • put each group into a Set and check if the Union is equal a Set individually.
  • do this process using the Uri and UriBuilder, and use them for the match verification after removing the "irrelevant" groups

--EDIT included Nick Berardi suggestion

Samuel Carrijo
Nick Berardi
Is this the same thing using different words...my mind is working overtime here:1) Rewrite the querystring on each URL by spliting and removing the unwanted "groups" and adding the groups back on in alphabetical order, then compare lowercase versions of the URL strings?
Mark Redman
This would work too. But you don't necessarily need to sort it (if you use Set instead)
Samuel Carrijo