Skip to content

Commit 1405f53

Browse files
gkalpakfilipesilva
authored andcommitted
fix(@schematics/angular): allow ServiceWorker to work with baseHref
Fixes #8515
1 parent a307f5e commit 1405f53

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/schematics/angular/service-worker/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function updateAppModule(options: ServiceWorkerOptions): Rule {
131131

132132
// register SW in app module
133133
const importText =
134-
`ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })`;
134+
`ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })`;
135135
moduleSource = getTsSourceFile(host, modulePath);
136136
const metadataChanges = addSymbolToNgModuleMetadata(
137137
moduleSource, modulePath, 'imports', importText);

packages/schematics/angular/service-worker/index_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ describe('Service Worker Schematic', () => {
8787
const tree = schematicRunner.runSchematic('service-worker', defaultOptions, appTree);
8888
const pkgText = tree.readContent('/projects/bar/src/app/app.module.ts');
8989
// tslint:disable-next-line:max-line-length
90-
const regex = /ServiceWorkerModule\.register\('\/ngsw-worker.js\', { enabled: environment.production }\)/;
91-
expect(pkgText).toMatch(regex);
90+
const expectedText = 'ServiceWorkerModule.register(\'ngsw-worker.js\', { enabled: environment.production })';
91+
expect(pkgText).toContain(expectedText);
9292
});
9393

9494
it('should put the ngsw-config.json file in the project root', () => {

0 commit comments

Comments
 (0)