don't assume api exists

This commit is contained in:
AJ ONeal 2015-11-21 12:46:13 +00:00
parent e45264673a
commit 4b083cf7d5
1 changed files with 4 additions and 1 deletions

View File

@ -236,11 +236,14 @@ function runApi(opts, router, req, res, next) {
// TODO compile packagesMap
// TODO people may want to use the framework in a non-framework way (i.e. to conceal the module name)
router.packages.some(function (_route) {
if (!_route.api) {
return;
}
var pathname = router.pathname;
if ('/' === pathname) {
pathname = '';
}
// TODO allow for special apis that do not follow convention (.well_known, webfinger, oauth3.html, etc)
if (!_route._api_re) {
_route._api_re = new RegExp(escapeStringRegexp(pathname + '/api/' + _route.api.id) + '\/([\\w\\.\\-]+)(\\/|\\?|$)');