Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import type { Connect, ViteDevServer } from 'vite';
import { loadEsmModule } from '../../../utils/load-esm';
import { AngularMemoryOutputFiles, pathnameWithoutBasePath } from '../utils';

const COMPONENT_REGEX = /%COMP%/g;

export function createAngularAssetsMiddleware(
server: ViteDevServer,
assets: Map<string, string>,
Expand Down Expand Up @@ -90,12 +88,13 @@ export function createAngularAssetsMiddleware(
// Shim the stylesheet if a component ID is provided
if (componentId.length > 0) {
// Validate component ID
if (/[_.-A-Za-z0-9]+-c\d{9}$/.test(componentId)) {
if (/^[_.\-\p{Letter}\d]+-c\d{9}$/u.test(componentId)) {
loadEsmModule<typeof import('@angular/compiler')>('@angular/compiler')
.then((compilerModule) => {
const encapsulatedData = compilerModule
.encapsulateStyle(new TextDecoder().decode(data))
.replaceAll(COMPONENT_REGEX, componentId);
const encapsulatedData = compilerModule.encapsulateStyle(
new TextDecoder().decode(data),
componentId,
);

res.setHeader('Content-Type', 'text/css');
res.setHeader('Cache-Control', 'no-cache');
Expand Down