Skip to content

Commit 167a424

Browse files
authored
Fix for Bug base62#57
Fixes If the input string starts with 0 then that 0 is lost during encoding.
1 parent e3bdf6d commit 167a424

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

base62.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ module.exports = (function (Base62) {
66
Base62.encode = function(integer){
77
if (integer === 0) {return '0';}
88
var s = '';
9-
while (integer > 0) {
9+
while (integer >= 0) {
1010
s = Base62.characterSet[integer % 62] + s;
11+
if (integer === 0)
12+
{
13+
break;
14+
}
1115
integer = Math.floor(integer/62);
1216
}
1317
return s;

0 commit comments

Comments
 (0)