From 922e7803e99de418d5f4723b955921b720b9d5c5 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 10 May 2017 11:54:05 +0200 Subject: [PATCH] remove extraneous slashes from hashes when parsing --- www/common/common-hash.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index d4c2bb112..a2e96e2fc 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -66,6 +66,10 @@ define([ return '/' + parsed.type + '/#' + parsed.hash; }; + var fixDuplicateSlashes = function (s) { + return s.replace(/\/+/g, '/'); + }; + /* * Returns all needed keys for a realtime channel * - no argument: use the URL hash or create one if it doesn't exist @@ -95,7 +99,7 @@ define([ } else { // New hash - var hashArray = hash.split('/'); + var hashArray = fixDuplicateSlashes(hash).split('/'); if (hashArray.length < 4) { Hash.alert("Unable to parse the key"); throw new Error("Unable to parse the key"); @@ -179,7 +183,7 @@ Version 2 parsed.version = 0; return parsed; } - var hashArr = hash.split('/'); + var hashArr = fixDuplicateSlashes(hash).split('/'); if (hashArr[1] && hashArr[1] === '1') { parsed.version = 1; parsed.mode = hashArr[2];