Files
blap/modules/widget-lifecycle/src/utils/matchPattern.ts
T
2026-06-08 10:32:12 +01:00

15 lines
511 B
TypeScript

/*
Copyright 2026 Element Creations Ltd.
Copyright 2023 Nordeck IT + Consulting GmbH
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
/**
* Checks if string matches pattern. Pattern can end with '*' to support prefix matching.
*/
export function matchPattern(value: string, pattern: string): boolean {
return pattern.endsWith("*") ? value.startsWith(pattern.slice(0, pattern.length - 1)) : value === pattern;
}