refactor: improve template input

This commit is contained in:
Carlos Valente
2025-02-18 14:49:18 +01:00
committed by Carlos Valente
parent 5fb30c75c4
commit 6b2e45e7de
4 changed files with 18 additions and 12 deletions
@@ -83,6 +83,16 @@ export function matchRemaining(a: string, b: string) {
return '';
}
// naive match assuming that a template will start with {{
if (a.endsWith('{{') && b.startsWith('{{')) {
return b.substring(2);
}
// naive match assuming that a template will start with {
if (a.endsWith('{') && b.startsWith('{{')) {
return b.substring(1);
}
for (let i = 0; i < b.length; i++) {
const searchString = b.substring(0, i + 1);
if (a.endsWith(searchString)) {