diff --git a/lib/main.js b/lib/main.js index 495a556..6576d02 100644 --- a/lib/main.js +++ b/lib/main.js @@ -174,6 +174,8 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps) { var appIdParts = appId.split('#'); var appIdPart; + res.setHeader('X-Walnut-Uri', appId.replace(/#/g, '/')); + // TODO configuration for allowing www if (/^www\./.test(req.hostname)) { // 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); - if (opts && opts.rewrite && -1 !== req.url.indexOf(appIdPart.replace(/#/, '/').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(/#/, '/').replace(/\/$/, '')) + appIdPart.replace(/\/$/, '').length); + if (opts && opts.rewrite && -1 !== req.url.indexOf(appIdPart.replace(/#/g, '/').replace(/\/$/, ''))) { + req.url = req.url.slice(req.url.indexOf(appIdPart.replace(/#/g, '/').replace(/\/$/, '')) + appIdPart.replace(/(\/|#)$/, '').length); if (0 !== req.url.indexOf('/')) { req.url = '/' + req.url; }