Created
August 27, 2014 11:53
-
-
Save tralamazza/c379c350654169de822a to your computer and use it in GitHub Desktop.
nodejs PoE passive skill tree encoded URL decoder
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
module.exports = function(str) { | |
var buf = Buffer(str.replace(/-/g, '+').replace(/_/g, '/'), 'base64'); | |
nodes = []; | |
for (var i = 6; i < buf.length; i += 2) | |
nodes.push(buf.readUInt16BE(i)); | |
return { | |
version: buf.readInt32BE(0), // just a guess | |
charClass: buf[4], | |
_: buf[5], // what's this? | |
nodes: nodes | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is for nodejs.
If anyone is interested in similar solution for browsers, change
Buffer
withatob
function, removing the second parameter (not that it hurts to leave it). And changebuf.readUInt16BE(i)
withbuf.charCodeAt(i)*256+buf.charCodeAt(i+1)
.You can similarly handle the version as 32bit int but it might be left as a set of 4 bytes too, we'll have to see if GGG take this to the semver direction or not.