update uri matching, set header

This commit is contained in:
AJ ONeal 2017-05-19 07:53:52 +00:00
parent 7159151352
commit 71819be266
1 changed files with 4 additions and 3 deletions

View File

@ -174,6 +174,8 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps) {
var appIdParts = appId.split('#'); var appIdParts = appId.split('#');
var appIdPart; var appIdPart;
res.setHeader('X-Walnut-Uri', appId.replace(/#/g, '/'));
// TODO configuration for allowing www // TODO configuration for allowing www
if (/^www\./.test(req.hostname)) { if (/^www\./.test(req.hostname)) {
// NOTE: acme responder and appcache unbricker must come before scrubTheDub // NOTE: acme responder and appcache unbricker must come before scrubTheDub
@ -246,9 +248,8 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps) {
} }
console.log('[serveStaticHelper] appIdPart', appIdPart); console.log('[serveStaticHelper] appIdPart', appIdPart);
if (opts && opts.rewrite && -1 !== req.url.indexOf(appIdPart.replace(/#/, '/').replace(/\/$/, ''))) { if (opts && opts.rewrite && -1 !== req.url.indexOf(appIdPart.replace(/#/g, '/').replace(/\/$/, ''))) {
console.log('[staticHelper ReWrite]', req.url.slice(req.url.indexOf(appIdPart.replace(/#/, '/').replace(/\/$/, '')) + appIdPart.replace(/\/$/, '').length)); req.url = req.url.slice(req.url.indexOf(appIdPart.replace(/#/g, '/').replace(/\/$/, '')) + appIdPart.replace(/(\/|#)$/, '').length);
req.url = req.url.slice(req.url.indexOf(appIdPart.replace(/#/, '/').replace(/\/$/, '')) + appIdPart.replace(/\/$/, '').length);
if (0 !== req.url.indexOf('/')) { if (0 !== req.url.indexOf('/')) {
req.url = '/' + req.url; req.url = '/' + req.url;
} }