Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Nov 21, 2024
1 parent 65911b0 commit 792e3ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLRewriter } from "./html_rewriter_wrapper.ts";
import { Element } from "./types.d.ts";

export { default as init } from "../pkg/html_rewriter.js";
import { default as init } from "../pkg/html_rewriter.js";

type Params = {
/**
Expand Down Expand Up @@ -60,7 +60,7 @@ function uInt8ArrayToBase64String(input: Uint8Array): string {
return btoa(res);
}

export function csp(originalResponse: Response, params?: Params) {
export async function csp(originalResponse: Response, params?: Params) {
const isHTMLResponse = originalResponse.headers.get("content-type")
?.startsWith(
"text/html",
Expand Down Expand Up @@ -147,6 +147,7 @@ export function csp(originalResponse: Response, params?: Params) {
}

const querySelectors = ["script", 'link[rel="preload"][as="script"]'];
await init()
return new HTMLRewriter()
.on(querySelectors.join(","), {
element(element: Element) {
Expand Down

0 comments on commit 792e3ff

Please sign in to comment.