I have built a website that displays one table record at a time. I have been using a URL fragment identifier (everything after the first #) to supply the record identifier, so to display the record with identifier '1', the URL would be: baseurl.org/record.html#1
In the code, I simply take window.location.hash, strip the leading #, and then query the table for the appropriate record identifier.
I recently found that certain URL shorteners will append things to the end of the URL, so some social media links to my site had '?platform=hootsuite' added to the end. Of course, my javascript can't find a record with the identifier '1?platform=hootsuite'
It's easy enough to write a short piece of javascript to extract the substring before a question mark, since I do not expect a question mark in my identifiers. The identifiers sometimes include letters as well, like 22a or 223C, but never special characters like ?, /, &, or #. I am wondering what other unexpected strings could be appended to my URL. I guess that anything appended would have to be preceded by a special character like a question mark, so I could come up with a list of special characters and ignore anything after those.
Is there a correct or conventional way to use the URL fragment and to handle things being appended to it? Are there other issues that might arise related to this simple way of using the URL fragment?
I'm just using html, javascript, and jQuery, and am not interested in a whole separate framework or library to handle this.