basic test of getDomainInfo, add ./var/.gitkeep
This commit is contained in:
parent
a8724cc502
commit
fc8e98173e
|
@ -0,0 +1,15 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.getDomainInfo = function (apppath) {
|
||||||
|
var parts = apppath.split(/[#%]+/);
|
||||||
|
var hostname = parts.shift();
|
||||||
|
var pathname = parts.join('/').replace(/\/+/g, '/').replace(/^\//, '');
|
||||||
|
|
||||||
|
return {
|
||||||
|
hostname: hostname
|
||||||
|
, pathname: pathname
|
||||||
|
, dirpathname: parts.join('#')
|
||||||
|
, dirname: apppath
|
||||||
|
, isRoot: apppath === hostname
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var utils = require('../lib/utils');
|
||||||
|
|
||||||
|
// TODO priority should be by arbitrarily, large numbers, not specific numbers of #
|
||||||
|
[
|
||||||
|
{ test: "example.com"
|
||||||
|
, result: { host: "example.com" }
|
||||||
|
}
|
||||||
|
, { test: "api.example.com"
|
||||||
|
, result: { host: "api.example.com" }
|
||||||
|
}
|
||||||
|
, { test: "api.example.com#"
|
||||||
|
, result: { host: "api.example.com" }
|
||||||
|
}
|
||||||
|
, { test: "api.example.com##"
|
||||||
|
, result: { host: "api.example.com" }
|
||||||
|
}
|
||||||
|
, { test: "api.example.com###"
|
||||||
|
, result: { host: "api.example.com" }
|
||||||
|
}
|
||||||
|
, { test: "example.com#blah"
|
||||||
|
, result: { host: "example.com" }
|
||||||
|
}
|
||||||
|
].forEach(function (sample) {
|
||||||
|
console.log(utils.getDomainInfo(sample.test));
|
||||||
|
});
|
Loading…
Reference in New Issue