Open nileshtrivedi opened 4 years ago
This will cover majority of the use-cases where portable identifiers are part of the URL. This will only miss those cases where the identifier like ISBN cannot be captured from the URL, but can be found in page content somewhere.
I can pick this up.
@deepaktatineni Great! Discuss here if needed, and send a PR!
Destination URLs should be able to take params from the current URL. For eg: if you are visiting a particular book on Amazon.com whose ISBN can be picked from the URL, the same ISBN can be passed on to the alternatives like OpenLibrary. This can be done by using named captures in the regexp which seems to be supported in Javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges
This will be useful for directly taking the user to exactly the right destination from a large set (products, books, research papers, or anything that comes from a large set and has a somewhat portable identifier).
Dynamic templating in pure JS can be achieved with a helper function like this: