Servers with more than one dot in title could not be handled

This commit is contained in:
Björn Dahlgren 2017-03-31 17:08:56 +02:00
parent f400d7efe9
commit fb6e731a81
2 changed files with 12 additions and 1 deletions

View File

@ -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
};

View File

@ -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'});