null+****@clear*****
null+****@clear*****
2012年 7月 12日 (木) 13:17:30 JST
SHIMODA Hiroshi 2012-07-12 13:17:30 +0900 (Thu, 12 Jul 2012) New Revision: 707ebf3ee6ad54a01b2e4e6e54c19b650a02df0f https://github.com/groonga/gcs/commit/707ebf3ee6ad54a01b2e4e6e54c19b650a02df0f Log: Add test for domain name detection from path Modified files: lib/domain.js test/domain.test.js Modified: lib/domain.js (+1 -1) =================================================================== --- lib/domain.js 2012-07-12 13:11:04 +0900 (fd6b0d2) +++ lib/domain.js 2012-07-12 13:17:30 +0900 (acd5c46) @@ -126,7 +126,7 @@ Domain.getNameFromHost = function(host) { }; Domain.getNameFromPath = function(path) { - var domainMatcher = /^\/gcs\/([^\/]+)\//; + var domainMatcher = /^\/gcs\/([^\/]+)/; var match = path.match(domainMatcher); if (match) Modified: test/domain.test.js (+19 -0) =================================================================== --- test/domain.test.js 2012-07-12 13:11:04 +0900 (4b2c69e) +++ test/domain.test.js 2012-07-12 13:17:30 +0900 (09597fe) @@ -124,6 +124,25 @@ suite('domain', function() { }); }); + suite('from path', function() { + test('valid', function() { + var host = 'example.com'; + var request = { headers: { host: host }, + url: '/gcs/test0123' }; + var domain = new Domain(request); + assert.equal(domain.name, 'test0123'); + }); + + test('invalid', function() { + assert.throw(function() { + var host = 'example.com'; + var request = { headers: { host: host }, + url: '/gcs/test_01234' }; + var domain = new Domain(request); + }, /cannot appear in a domain name/); + }); + }); + suite('getNameFromPath', function() { test('valid, lower case and number', function() { var path = '/gcs/test0123/'; -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...下載