Skip to content

Instantly share code, notes, and snippets.

@robert-blankenship
Last active December 2, 2015 01:28
Show Gist options
  • Save robert-blankenship/dc1e656e5f649d3f76d9 to your computer and use it in GitHub Desktop.
Save robert-blankenship/dc1e656e5f649d3f76d9 to your computer and use it in GitHub Desktop.
function formatUrl(linkUrl) {
if (linkUrl[0] == "/") {
var append1 = "http://";
var originalUrl = linkUrl;
var newUrl = linkUrl.replace("//", append1); // this doesn't actually change linkUrl
if (originalUrl !== newUrl) {
console.log("linkUrl: ", linkUrl);
console.log("originalUrl: ", originalUrl);
console.log("newUrl: ", newUrl);
}
return linkUrl;
} else {
return linkUrl;
}
};
formatUrl("//google.com");
formatUrl("http://google.com");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment