Padding out ip_as_username hex values
authorDarren <darren@darrenwhitlen.com>
Sun, 9 Jun 2013 17:16:21 +0000 (18:16 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 9 Jun 2013 17:16:21 +0000 (18:16 +0100)
server/irc/connection.js

index cf155709436a9f5f55110c7128ee81183f890a73..ae0100e7f4af3d85fec4045335feaf7d6a2c977f 100644 (file)
@@ -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('');
 
     }