Skip to content

Commit

Permalink
fix(docs-infra): pass a TrustedScriptURL to ServiceWorkerModule (#43406)
Browse files Browse the repository at this point in the history
Fix a Trusted Types violation in ServiceWorkerModule that occurs when
initializing the service worker from a string URL, by passing a
TrustedScriptURL instead.

PR Close #43406
  • Loading branch information
bjarkler authored and AndrewKushnir committed Sep 10, 2021
1 parent 586302a commit e5ee5a2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aio/src/app/app.module.ts
Expand Up @@ -13,6 +13,7 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { MatToolbarModule } from '@angular/material/toolbar';

import { svg } from 'app/shared/security';
import { scriptUrl, unwrapScriptUrlForSink } from 'safevalues';

import { AppComponent } from 'app/app.component';
import { CustomIconRegistry, SVG_ICONS } from 'app/shared/custom-icon-registry';
Expand Down Expand Up @@ -156,7 +157,10 @@ export const svgIconProviders = [
MatToolbarModule,
SwUpdatesModule,
SharedModule,
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
ServiceWorkerModule.register(
// Make sure service worker is loaded with a TrustedScriptURL
unwrapScriptUrlForSink(scriptUrl`/ngsw-worker.js`),
{enabled: environment.production}),
],
declarations: [
AppComponent,
Expand Down

0 comments on commit e5ee5a2

Please sign in to comment.