Vesper.js is a tiny library to detect same-origin redirects.
In English, if /your/page contains a link to /foo, and /foo redirects to /bar, you could detect the /foo -> /bar redirect and do something, such as passively record /your/page as requiring old URLs to be updated.
<script src="vesper.js"></script>
<script>
Vesper.configure({
onRedirected: function(redirectSource, redirectTarget, originatingPage) {
console.log("redirect from " + redirectSource + " to " + redirectTarget);
console.log("redirect found on " + originatingPage);
}
});
</script>
Vesper has no dependencies, but does rely on two features from HTML5:
* Navigation Timing, specifically window.performance.navigation
* Web Storage, specifically sessionStorage
Due to browser restrictions, redirects can only be detected if both source and target satisfy the same-origin policy.
Thanks to Peter Cooper http://peterc.org/ for the name.
Copyright (c) 2013 Adam Prescott https://aprescott.com.
Vesper is released under the MIT license. See LICENSE for details.
The quickest way to get changes contributed:
- Visit the GitHub repository for Vesper.
- Fork the repository.
- Check out a branch on the latest master for your change:
git checkout -b master new-feature
--- do not make changes onmaster
! - Send a pull request on GitHub, including a description of what you've changed.