Skip to content
Snippets Groups Projects
Commit 1edb2512 authored by Valentin Schabschneider's avatar Valentin Schabschneider
Browse files

Add ability to use path and urls for styles and scripts

parent 32a98dfb
Branches main
No related tags found
No related merge requests found
Pipeline #46330 failed with stages
in 52 seconds
...@@ -166,7 +166,7 @@ class Printer extends EventEmitter { ...@@ -166,7 +166,7 @@ class Printer extends EventEmitter {
for (const style of this.styles) { for (const style of this.styles) {
await page.addStyleTag({ await page.addStyleTag({
path: style [this.isUrl(style) ? "url" : "path"]: style
}); });
} }
...@@ -176,7 +176,7 @@ class Printer extends EventEmitter { ...@@ -176,7 +176,7 @@ class Printer extends EventEmitter {
for (const script of this.additionalScripts) { for (const script of this.additionalScripts) {
await page.addScriptTag({ await page.addScriptTag({
path: script [this.isUrl(script) ? "url" : "path"]: script
}); });
} }
...@@ -386,6 +386,15 @@ class Printer extends EventEmitter { ...@@ -386,6 +386,15 @@ class Printer extends EventEmitter {
return this.allowedDomains.includes(domain); return this.allowedDomains.includes(domain);
} }
isUrl(resource) {
try {
new URL(resource);
return true;
} catch {
return false;
}
}
} }
export default Printer; export default Printer;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment