feat: add nonce for inline scripts (#1772)
This commit is contained in:
@@ -35,6 +35,7 @@ export class RenderState {
|
||||
// Preact state
|
||||
ownerStack: VNode[] = [];
|
||||
owners = new Map<VNode, VNode>();
|
||||
#nonce = "";
|
||||
|
||||
constructor(
|
||||
routeOptions: RenderStateRouteOptions,
|
||||
@@ -50,6 +51,13 @@ export class RenderState {
|
||||
if (error) this.routeOptions.error = error;
|
||||
}
|
||||
|
||||
getNonce(): string {
|
||||
if (this.#nonce === "") {
|
||||
this.#nonce = crypto.randomUUID().replace(/-/g, "");
|
||||
}
|
||||
return this.#nonce;
|
||||
}
|
||||
|
||||
clearTmpState() {
|
||||
this.renderingUserTemplate = false;
|
||||
this.ownerStack = [];
|
||||
|
||||
Reference in New Issue
Block a user