From 59734b448ac6f1c09ab88eb8cc73c883f0a9a3b9 Mon Sep 17 00:00:00 2001 From: Sahin Vardar Date: Tue, 30 May 2023 18:04:24 +0200 Subject: [PATCH] fix: stripScriptTag --- package.json | 2 +- src/i18n-preprocessor.ts | 2 +- src/utils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a8690b0..d89ee0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vardario/svelte-i18next", - "version": "0.1.0", + "version": "0.1.1", "description": "", "license": "MIT", "author": "Sahin Vardar", diff --git a/src/i18n-preprocessor.ts b/src/i18n-preprocessor.ts index db4056a..f49b1ce 100644 --- a/src/i18n-preprocessor.ts +++ b/src/i18n-preprocessor.ts @@ -105,7 +105,7 @@ export const i18nProcessor = (options?: I18nProcessorOptions): PreprocessorGroup adjustI18nKeys(ast, keyPath, callIdentifier); const transformedCode = printHtml({ ast, indent: options?.indent }); - const result = `${scriptTags.join('\n')}${scriptTags.length ? "'n" : ''}${transformedCode}`; + const result = `${scriptTags.join('\n')}${scriptTags.length ? '\n' : ''}${transformedCode}`; return { code: result }; } return { diff --git a/src/utils.ts b/src/utils.ts index 262e9df..ffd3094 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -30,7 +30,7 @@ export async function scanDir(dir: string, filter?: (file: string) => boolean) { } export function stripScriptTag(code: string) { - const scriptTagRegEx = /<.*?script.*?>(.*?)<\/.*?script.*?>/gi; + const scriptTagRegEx = /([\s\S]*?<\/script>)/gi; const scriptTags: string[] = []; for (const match of code.matchAll(scriptTagRegEx)) {