fix(sbt): Use indexOf instead of search (#5085)

This commit is contained in:
Sergio Zharinov 2020-01-01 21:09:43 +04:00 committed by Rhys Arkins
parent e1ebe77781
commit 0836d91c2f

View file

@ -50,7 +50,7 @@ const getVarInfo = (
): { val: string; fileReplacePosition: number } => { ): { val: string; fileReplacePosition: number } => {
const { fileOffset } = ctx; const { fileOffset } = ctx;
const rightPart = str.replace(/^\s*val\s+[_a-zA-Z][_a-zA-Z0-9]*\s*=\s*"/, ''); const rightPart = str.replace(/^\s*val\s+[_a-zA-Z][_a-zA-Z0-9]*\s*=\s*"/, '');
const fileReplacePosition = str.search(rightPart) + fileOffset; const fileReplacePosition = str.indexOf(rightPart) + fileOffset;
const val = rightPart.replace(/"\s*$/, ''); const val = rightPart.replace(/"\s*$/, '');
return { val, fileReplacePosition }; return { val, fileReplacePosition };
}; };
@ -118,11 +118,13 @@ function parseDepExpr(
// help us to avoid errors in updating phase. // help us to avoid errors in updating phase.
fileReplacePosition = 0; fileReplacePosition = 0;
fileReplacePosition += fileReplacePosition +=
expr.slice(fileReplacePosition).search(rawGroupId) + rawGroupId.length; expr.slice(fileReplacePosition).indexOf(rawGroupId) + rawGroupId.length;
fileReplacePosition += fileReplacePosition +=
expr.slice(fileReplacePosition).search(rawArtifactId) + expr.slice(fileReplacePosition).indexOf(rawArtifactId) +
rawArtifactId.length; rawArtifactId.length;
fileReplacePosition += expr.slice(fileReplacePosition).search(currentValue); fileReplacePosition += expr
.slice(fileReplacePosition)
.indexOf(currentValue);
fileReplacePosition += fileOffset; fileReplacePosition += fileOffset;
} else { } else {
fileReplacePosition = variables[rawVersion].fileReplacePosition; fileReplacePosition = variables[rawVersion].fileReplacePosition;