Skip to content

Instantly share code, notes, and snippets.

@tralamazza
Created August 27, 2014 11:53
Show Gist options
  • Save tralamazza/c379c350654169de822a to your computer and use it in GitHub Desktop.
Save tralamazza/c379c350654169de822a to your computer and use it in GitHub Desktop.
nodejs PoE passive skill tree encoded URL decoder
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
};
};
@georgir
Copy link

georgir commented Jan 4, 2016

This code is for nodejs.

If anyone is interested in similar solution for browsers, change Buffer with atob function, removing the second parameter (not that it hurts to leave it). And change buf.readUInt16BE(i) with buf.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment