From: Darren Date: Sun, 9 Jun 2013 17:16:21 +0000 (+0100) Subject: Padding out ip_as_username hex values X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=32800bf59913aad7ce91d0effe9b00014b883720;p=KiwiIRC.git Padding out ip_as_username hex values --- diff --git a/server/irc/connection.js b/server/irc/connection.js index cf15570..ae0100e 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -392,7 +392,13 @@ function findWebIrc(connect_data) { if (ip_as_username && ip_as_username.indexOf(this.irc_host.hostname) > -1) { // Get a hex value of the clients IP this.username = this.user.address.split('.').map(function(i, idx){ - return parseInt(i, 10).toString(16); + var hex = parseInt(i, 10).toString(16); + + // Pad out the hex value if it's a single char + if (hex.length === 1) + hex = '0' + hex; + + return hex; }).join(''); }