diff --git a/lib/server.js b/lib/server.js index 4357e64..5201e82 100644 --- a/lib/server.js +++ b/lib/server.js @@ -40,6 +40,10 @@ var Server = function (config, logs, options) { Server.prototype = new events.EventEmitter(); +Server.prototype.generateId = function () { + return slugify(this.title).replace(/\./g, '-'); +}; + Server.prototype.update = function (options) { this.admin_password = options.admin_password; this.auto_start = options.auto_start; @@ -55,7 +59,7 @@ Server.prototype.update = function (options) { this.title = options.title; this.von = options.von; - this.id = slugify(this.title).replace('.', '-'); + this.id = this.generateId(); this.port = parseInt(this.port, 10); // If port is a string then gamedig fails }; diff --git a/test/lib/server.js b/test/lib/server.js index e30aacd..524db5e 100644 --- a/test/lib/server.js +++ b/test/lib/server.js @@ -3,6 +3,13 @@ var should = require('should'); var Server = require('../../lib/server.js'); describe('Server', function() { + describe('generateId()', function() { + it('should include title', function() { + var server = new Server(null, null, {title: 'title.with.lot.of.dots'}); + server.generateId().should.eql('title-with-lot-of-dots'); + }); + }); + describe('toJSON()', function() { it('should include title', function() { var server = new Server(null, null, {title: 'test'});