Skip to content

Commit

Permalink
fix: add /b escaping and remove redundant escaping when download
Browse files Browse the repository at this point in the history
  • Loading branch information
KateDronova committed May 6, 2024
1 parent 9cd164d commit 567d32e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/features/locators/utils/escapeLocatorString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const fullEscapeLocatorString = (str: string = ''): string => {
.replaceAll(/\\/g, '\\\\') // escape backslash
.replaceAll(/\"/g, '\\"') // escape double quotes
.replaceAll(/\'/g, "\\'") // escape single quotes
.replaceAll(/\b/g, '\\b') // escape backspaces
.replaceAll(/\t/g, '\\t') // escape tabs
.replaceAll(/\n/g, '\\n') // escape newlines
.replaceAll(/\r/g, '\\r') // escape carriage returns
Expand Down
4 changes: 2 additions & 2 deletions src/features/pageObjects/utils/pageObjectTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export const getPageObjectTemplateForJdi = (
const { name: className, library } = pageObject;

const locatorsCode = locators.map((locator) => {
const locatorEscaped = locator.locatorValue.output?.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
const locatorOutput = locator.locatorValue.output;
const { locatorType } = pageObject;
const currentLocatorType = locator.locatorType || locatorType || LocatorType.xPath;
return ` ${locator.annotationType}(${getLocatorPrefix(
locator.annotationType,
currentLocatorType,
)}"${locatorEscaped}")\n public ${locator.type} ${locator.name};`;
)}"${locatorOutput}")\n public ${locator.type} ${locator.name};`;
});

const hasFindByAnnotationType: boolean = hasAnnotationType(locators, AnnotationType.FindBy);
Expand Down

0 comments on commit 567d32e

Please sign in to comment.