From f60ddbe3cb9ab0c8c34de674815aff7512813223 Mon Sep 17 00:00:00 2001 From: Guillaume ROUCHON Date: Thu, 16 Apr 2020 14:59:07 +0200 Subject: [PATCH] Fix token prefix not as token prefix (#150) --- README.md | 3 +++ task/index.ts | 2 +- task/task.json | 2 +- vss-extension.json | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7de6961..0ce61e3 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ If you want to use tokens in XML based configuration files to be replaced during - replace tokens in your updated configuration file ## Release notes +**New in 3.5.2** +- Fix issue when token prefix present but not as a token prefix ([#149](https://github.com/qetza/vsts-replacetokens-task/issues/149)). + **New in 3.5.1** - Fix issue when variable `System.ServerType` is not defined ([#147](https://github.com/qetza/vsts-replacetokens-task/issues/147)). diff --git a/task/index.ts b/task/index.ts index 9ca0a03..1997794 100644 --- a/task/index.ts +++ b/task/index.ts @@ -504,7 +504,7 @@ async function run() { // initialize task let escapedTokenPrefix: string = tokenPrefix.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); let escapedTokenSuffix: string = tokenSuffix.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); - let regex: RegExp = new RegExp(escapedTokenPrefix + '\\s*((?:(?!\\s*' + escapedTokenSuffix + ').)*)\\s*' + escapedTokenSuffix, 'gm'); + let regex: RegExp = new RegExp(escapedTokenPrefix + '\\s*((?:(?!' + escapedTokenPrefix + ')(?!\\s*' + escapedTokenSuffix + ').)*)\\s*' + escapedTokenSuffix, 'gm'); logger.debug('pattern: ' + regex.source); // set telemetry data diff --git a/task/task.json b/task/task.json index 6000644..fb03125 100644 --- a/task/task.json +++ b/task/task.json @@ -13,7 +13,7 @@ "version": { "Major": 3, "Minor": 5, - "Patch": 1 + "Patch": 2 }, "instanceNameFormat": "Replace tokens in $(targetFiles)", "minimumAgentVersion": "2.105.0", diff --git a/vss-extension.json b/vss-extension.json index 779c2d7..b5c3e6d 100644 --- a/vss-extension.json +++ b/vss-extension.json @@ -2,7 +2,7 @@ "manifestVersion": 1, "id": "replacetokens", "name": "Replace Tokens", - "version": "3.5.1", + "version": "3.5.2", "public": true, "publisher": "qetza", "targets": [