In order to perform AJAX calls, I extract URL values (embedded IDs and query string parameters) and store them in hidden inputs. Outside of this little bit of server-side work, I have a static HTML page.
I am looking for a library that can easily extract my URL values on the client-side. I'd like to specify the expected format (a URL template if you will): /account/{accountId}/edit?param={param}
. Then I'd like the library to create an object based on the actual URL (based on window.location
): /account/123/edit?param=234
and give me back an object: { accountId: 123, param: 234 }
.
It would be nice if the library would allow me to indicate the expected type {accountId:int}
so that the resulting object has a true, int, float, date, etc.
Does such a library exist for client-side JavaScript?