ARTICLE AD BOX
Most other questions I have found about this topic entail having GET parameters à la base-url.com/route?param=value. However, my application uses routes similar to
base-url.com/resources/1 base-url.com/resources/edit/1and I want to extract the entire path name of the URL/URI except for any resource IDs at the end (/resources and /resources/edit respectively).
I've tried doing something like
let path = /^\D+/.exec(window.location.pathname)[0]; // string until first number path = path.replace(/\/+$/, ''); // removes the slash at the endto get everything until the first digit (because the IDs in my use cases are digits). Does anyone know of a more secure/foolproof way of doing this?
