From 2e0c8327989700653802bcf9b3aac75b91f4e366 Mon Sep 17 00:00:00 2001 From: Jonathan Roig Date: Tue, 25 Jul 2017 22:20:36 -0700 Subject: [PATCH] better path handling --- emojiurlifier.js | 2 +- index.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/emojiurlifier.js b/emojiurlifier.js index 565abea..47c9dec 100644 --- a/emojiurlifier.js +++ b/emojiurlifier.js @@ -1 +1 @@ -var emojiurlifier=function(emojiDomain,standardDomain){console.log("Emoji Domain Progressive Enhancement by https://i❤️.ws");var wl=window.location;var useEmojiDomain=/^((?!chrome).)*safari/i.test(navigator.userAgent);if(navigator.userAgent.indexOf("CriOS")>-1){useEmojiDomain=false}var currentUrl=wl.protocol+"//"+wl.hostname;var outputUrl=useEmojiDomain?emojiDomain:standardDomain;if(currentUrl===outputUrl){return}if(wl.port){outputUrl+=":"+wl.port}outputUrl+=wl.pathname;window.location=outputUrl}; +var emojiurlifier=function(emojiDomain,standardDomain){console.log("Emoji Domain Progressive Enhancement by https://i❤️.ws");console.log("Learn more at https://github.com/jonroig/emojiurlifier");var wl=window.location;var useEmojiDomain=/^((?!chrome).)*safari/i.test(navigator.userAgent);if(navigator.userAgent.indexOf("CriOS")>-1){useEmojiDomain=false}var currentUrl=wl.protocol+"//"+wl.hostname;var outputUrl=useEmojiDomain?emojiDomain:standardDomain;if(currentUrl===outputUrl){return}if(wl.port){outputUrl+=":"+wl.port}outputUrl+=wl.pathname;outputUrl+=wl.search;window.location=outputUrl}; diff --git a/index.js b/index.js index e591e09..89847ad 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ var emojiurlifier = function (emojiDomain, standardDomain) { - console.log('Emoji Domain Progressive Enhancement by https://i❤️.ws') + console.log('Emoji Domain Progressive Enhancement by https://i❤️.ws'); + console.log('Learn more at https://github.com/jonroig/emojiurlifier'); + var wl = window.location; var useEmojiDomain = /^((?!chrome).)*safari/i.test(navigator.userAgent); if (navigator.userAgent.indexOf('CriOS') > -1) { @@ -8,7 +10,6 @@ var emojiurlifier = function (emojiDomain, standardDomain) { var currentUrl = wl.protocol + '//' + wl.hostname; var outputUrl = useEmojiDomain ? emojiDomain : standardDomain; - console.log(currentUrl, outputUrl); if (currentUrl === outputUrl) { return; } @@ -16,5 +17,6 @@ var emojiurlifier = function (emojiDomain, standardDomain) { outputUrl += ':'+wl.port; } outputUrl += wl.pathname; + outputUrl += wl.search; window.location = outputUrl; }