mercredi 29 juillet 2015

How to check rails params hash from url query parameter contains double quoted string?

I created a GET endpoint to serve an API using rails. I want to be able to check for when the user passes double quotes for the query parameter in the url.

So for example the user could call the below endpoint by passing the query parameter with double quotes or no quotes. My application is expected to behave differently if the double quotes are found in the query params..

localhost:8080/company/data.json?q="America Online in UK"&size=10

Now the user can also call the endpoint with no double quotes like this:

localhost:8080/company/data.json?q=America+Online+in+UK&size=10

OR

localhost:8080/company/data.json?q=AOL&size=10

How do I handle the above use-cases in a rails controller with respect to spaces and double quotes?

Aucun commentaire:

Enregistrer un commentaire