Created
February 20, 2018 01:05
-
-
Save t-laird/d4d1860f7eece8b04bfb4cc610bb4303 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 segmentCount = 0; | |
var l = window.location; | |
const nonHomeUrls = ['/snap-ninja', '/Headcount', '/comp-3', '/Centipede']; | |
for (let i = 0; i < nonHomeUrls.length; i++) { | |
const urlRegex = new RegExp(nonHomeUrls[i], 'i'); | |
const verifyUrl = urlRegex.test(l.pathname); | |
if (!verifyUrl) { | |
l.replace( | |
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + | |
l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' + | |
l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') + | |
(l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') + | |
l.hash | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment