@qpoint/mask-urls
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -7,3 +7,4 @@ import { Context } from '@qpoint/router'; | ||
appUrl?: string; | ||
maskAssets?: boolean; | ||
} | ||
export default function rewriteHtml(config?: MaskUrlsConfig): (ctx: Context, next: Function) => any; |
@@ -18,8 +18,16 @@ "use strict"; | ||
config = ctx.state['mask-urls.config']; | ||
// attach to the rewriter | ||
// generate an assets config | ||
const assetsConfig = { | ||
...config, | ||
...(!config.maskAssets && { | ||
absolute: true, | ||
edgeUrl: config.edgeUrl || config.appUrl || ctx.pxy.url | ||
}), | ||
}; | ||
// add rewrite rules | ||
ctx.htmlRewriter | ||
.on("a", new url_rewriter_1.UrlRewriter('href', ctx, config)) | ||
.on("link", new url_rewriter_1.UrlRewriter('href', ctx, config)) | ||
.on("img", new url_rewriter_1.UrlRewriter('src', ctx, config)) | ||
.on("script", new url_rewriter_1.UrlRewriter('src', ctx, config)); | ||
.on("link", new url_rewriter_1.UrlRewriter('href', ctx, assetsConfig)) | ||
.on("img", new url_rewriter_1.UrlRewriter('src', ctx, assetsConfig)) | ||
.on("script", new url_rewriter_1.UrlRewriter('src', ctx, assetsConfig)); | ||
// continue along | ||
@@ -26,0 +34,0 @@ return next(); |
{ | ||
"name": "@qpoint/mask-urls", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A Qpoint adapter for masking URLs behind a reverse proxy", | ||
@@ -5,0 +5,0 @@ "author": "Tyler Flint <tyler@qpoint.io>", |
Sorry, the diff of this file is not supported yet
20031
111