Commit 14167248 authored by Aaron Tidwell's avatar Aaron Tidwell

fix getRawSubdomain not handling subdomains with dashes

parent de141c81
......@@ -14,7 +14,11 @@ var Tournaments = exports.Tournaments = function(options) {
Client.call(this, options); // call parent constructor
this.getRawSubdomain = function() {
return this.options.get('subdomain').replace('-', '');
const subdomain = this.options.get('subdomain');
if (this.options.get('subdomain')[subdomain.length - 1] === '-') {
return subdomain.substr(0, subdomain.length - 1);
}
return subdomain;
};
};
......
......@@ -13,6 +13,34 @@ describe('tournaments endpoints', () => {
});
});
describe('getRawSubdomain', () => {
it('should return the subdomain', () => {
tournamentsInstance.options.subdomain = 'mysubdomain-';
const domain = tournamentsInstance.getRawSubdomain();
expect(domain).toEqual('mysubdomain');
});
it('should only strip a trailing dash from a subdomain', () => {
tournamentsInstance.options.subdomain = 'my-sub-domain-';
const domain = tournamentsInstance.getRawSubdomain();
expect(domain).toEqual('my-sub-domain');
});
it('should return raw if there is no -', () => {
tournamentsInstance.options.subdomain = 'raw';
const domain = tournamentsInstance.getRawSubdomain();
expect(domain).toEqual('raw');
});
it('should return nothing if no subdomain -', () => {
const domain = tournamentsInstance.getRawSubdomain();
expect(domain).toEqual('');
});
})
// index GET tournaments
describe('index', () => {
it('should create an appropriate url without a subdomain', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment