Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Zendesk</title>
- <script type="text/javascript">// setup redirect so that redirect triggers
- setupRedirect();
- /**
- * Redirect (Segment is temporarily disabled so we have zero tracking)
- */
- function setupRedirect() {
- var redirectFunc = function() {
- window.location = getDestinationUrl();
- };
- redirectFunc();
- }
- /**
- * Returns the destination of the redirect. Drip email URLs are expected to
- * be of the form ?subdomain={$1}&path=${$2} or ?path={$1}&subdomain={$1}
- * For example: ?subdomain=zobu&path=agent/discovery
- *
- * @returns {string}
- */
- function getDestinationUrl() {
- var href = window.location.href;
- var query = href.slice(href.indexOf('?') + 1).replace(/%2f/ig, '/');
- var params = {};
- var paramStrs = query.split('&');
- var i, kv;
- for (i = 0; i < paramStrs.length; i++) {
- kv = paramStrs[i].split('=', 2);
- params[kv[0]] = kv[1];
- }
- function remainingParamsString() {
- return Object.keys(params).filter(function(k) {
- return ['subdomain', 'path'].indexOf(k) < 0;
- }).map(function(k) {
- return k + '=' + params[k];
- }).join('&');
- }
- if (params.subdomain) {
- params.subdomain = params.subdomain.replace(/[^A-Za-z0-9-]/g, '');
- }
- if (params.path) {
- params.path = params.path.replace(/[^A-Za-z0-9-/_]/g, '');
- }
- if (params.subdomain && params.path) {
- return 'https://' + params.subdomain + '.zendesk.com/' + params.path + '?' + remainingParamsString();
- } else {
- return 'https://' + window.location.host;
- }
- }</script>
- </head>
- <body></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement