writing tests for pageKey function, fixing always added padding bug
This commit is contained in:
@@ -290,31 +290,16 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
*/
|
||||
pageKey: function()
|
||||
{
|
||||
var key = window.location.hash.substring(1),
|
||||
i = key.indexOf('&');
|
||||
|
||||
// Some web 2.0 services and redirectors add data AFTER the anchor
|
||||
// (such as &utm_source=...). We will strip any additional data.
|
||||
|
||||
var key = window.location.hash.substring(1), // Get key
|
||||
i = key.indexOf('=');
|
||||
|
||||
// First, strip everything after the equal sign (=) which signals end of base64 string.
|
||||
if (i > -1)
|
||||
{
|
||||
key = key.substring(0, i + 1);
|
||||
}
|
||||
|
||||
// If the equal sign was not present, some parameters may remain:
|
||||
i = key.indexOf('&');
|
||||
if (i > -1)
|
||||
{
|
||||
key = key.substring(0, i);
|
||||
}
|
||||
|
||||
// Then add trailing equal sign if it's missing
|
||||
if (key.charAt(key.length - 1) !== '=')
|
||||
{
|
||||
key += '=';
|
||||
}
|
||||
|
||||
return key;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user