localStorage is per domain/sub-domain, but I need to store and retrieve values per page.
Does anyone have an expression that removes the domain, bookmarks and query-string from the location? I can then use encodeURIComponent and prepend each localStorage-key with this value.
In which case, I also need the ‘reverse’ to this expression in order to retrieve values just for the current page. EDITED I don’t think I need a ‘reverse’ function – it would be the same expression.
If I have the two expression above, would you use this (stripped) location as a single key-entry, and stringify all the values I need for the page within it? This might be preferable as I can just check the location once to discover if it has any corrresponding localStorage.
I have a function that generates a key for me, based on the page name (gotten from window.location) and appended with what the key would have been, then I store the data in localstorage.