Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Icon): correct prepareStringData #1096

Merged
merged 2 commits into from
Nov 7, 2023
Merged

Conversation

DarkGenius
Copy link
Contributor

No description provided.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

it('should remove width and height only inside svg tag', () => {
const data =
'<svg width="100" viewBox="0 0 200 200" height="200">\n<rect x="50" y="50" width="100" height="100" fill="red" />\n</svg>';
expect(prepareStringData(data)).toEqual(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.toBe is more straightforward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.toBe is specifically useful for reference equality, for string comparison there is no difference here

@@ -22,7 +22,12 @@ export function isStringSvgData(data: SVGIconData): data is SVGIconStringData {
return typeof data === 'string';
}
export function prepareStringData(data: SVGIconStringData) {
return data.replace(/(width|height)=(["']?)\d+\2/g, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the same logic for quotes

@DarkGenius DarkGenius merged commit 8e4817e into main Nov 7, 2023
3 checks passed
@DarkGenius DarkGenius deleted the fix-icon-prepareStringData branch November 7, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants