0
I Use This!
Activity Not Available
Analyzed 10 months ago. based on code collected 10 months ago.

Project Summary

The Endpoint Resolver is a simple library that takes a URL and returns the final destination of that URL. It tries to follow a Location: header.

How it worksGiven the URL, it gets passes to a server side resolver that hits the URL to get the headers. If a Location: header appears it is a redirect (ignoring 301, 302 for now, so a 200 + Location would count).

Since this happens via JSONP, it happens asynchronously via appending the script to the DOM. This is why you pass in a callback that will be passed the new URL, and the original one.

If the URL has been changed they will of course be different, and a simple helper Endpoint.isRedirecting(url, orig) will do that test for you.

Why?The reason I built this was for a Twitter client. Seeing tinyurl / snurl / is.gd / twurl / .... URLs is ugly, and it can be scary not knowing where you are going, so wouldn't it be nice to convert them back to the real URL?

Examples// Simplest version
Endpoint.resolve('http://snurl.com/2luj3', function(url) {
alert(url);
});

// Used in the form below
Endpoint.resolve(
document.getElementById('testurl').value,
function(url) { alert(url); }
);
// Using the original URL to work out if it has changed
Endpoint.resolve(
document.getElementById('testurl').value,
function(url, orig) {
alert(url);
alert(Endpoint.isRedirecting(url, orig));
}
);

Tags

endpoint http twitter javascript url redirect ajax php

In a Nutshell, endpoint-resolver...

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    you can embed statistics from Open Hub on your site
  • ...
    55% of companies leverage OSS for production infrastructure
  • ...
    learn about Open Hub updates and features on the Open Hub blog

30 Day Summary

Apr 9 2016 — May 9 2016

12 Month Summary

May 9 2015 — May 9 2016

Ratings

Be the first to rate this project
Click to add your rating
   Spinner
Review this Project!