Created
April 29, 2013 09:43
-
-
Save rhumlover/5480670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _embedder = (function(doc) { | |
var referrer = doc.referrer, | |
anchor = doc.createElement('a'), | |
res = [referrer]; | |
/* | |
Two different ways to extract domain from url: | |
- for only one part, we can use a fast regexp: referrer.match(/:\/\/(.[^/]+)/)[1]) | |
- for 2+ parts, create manually a '<a>' tag, set his href to the referrer url, and | |
then we can access to several url infos: protocol, hostname, port... | |
(@see https://gist.github.com/jlong/2428561) | |
*/ | |
anchor.href = referrer; | |
res.push(anchor.protocol + '//' + anchor.hostname); | |
return res.join(' | '); | |
}(document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment