Recently we had an unusual scenario while working on a project. We were working with an external team, who was supposed to deliver to us a set number of parameters via a unique URL.
The correct URL, when passed back to us should be in this format:
https://someurl.com?parameter1=value1¶meter2=value2¶meter3=value3
Unfortunately, due to an unexplainable error with the team, we kept receiving
https://someurl.com?parameter1=value1?parameter2=value2¶meter3=value3
Obviously, that 2nd question mark in the middle messed up a lot of our URL detection. Our server would not work with the ? in the middle. With the project deadline looming dangerously ahead, and no changes expected from the external team, what do we do?
The solution was simple, however in-elegant it might be:
We called window.location.href, and searched for the exact wrong string (" ?parameter2=value2 " ).
We then coded the logic:
If the string above exists, redirect to a brand new window.location.href, with the "?" removed.
We then placed the code right at the top of the HTML page, making sure other scripts won't load if the erroneous string was detected.
Voila, the trick worked! Temporary fix, that is.