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

[BUG] removeSiteLocaleFromPath Function in retail-react-app Module Replacing Unintended Characters #2074

Open
mohammedjamboo-pandora opened this issue Oct 11, 2024 · 3 comments
Labels
Acknowledged Team has responded to issue BUG P3 git2gus label for bug

Comments

@mohammedjamboo-pandora
Copy link

Description: We encountered an issue in the removeSiteLocaleFromPath function within the url.js file of the retail-react-app module. Currently, the function uses the following regular expression to replace all matching characters related to the siteRef:

pathName.replace(new RegExp(`/${siteRef}`, 'g'), '')

Issue: This regex replaces all occurrences of characters related to the siteRef across the entire path. However, some of our category names also include the same locale characters, which leads to unintended replacements. This affects the proper categorization and navigation.

Suggested Fix: We recommend modifying the regular expression to replace only the first occurrence of the siteRef, rather than all matches. You could implement this by removing the global ('g') flag, like so:

pathName.replace(new RegExp(`/${siteRef}`), '')

This would ensure only the first match is replaced, preserving the integrity of category names and other path segments.

Please let me know if you need more information or have any questions regarding this issue.

@alexvuong
Copy link
Collaborator

alexvuong commented Oct 15, 2024

Thanks for the issue @mohammedjamboo-pandora. We will look into this and will allocate resource to work as we see fit.
Which PWA Kit version are you on? If you are on v3, do you use extensibility?
Could you give us a few examples of what urls (cate with locale) you mentioned?

@alexvuong alexvuong added Acknowledged Team has responded to issue BUG P3 git2gus label for bug labels Oct 15, 2024
Copy link

git2gus bot commented Oct 15, 2024

This issue has been linked to a new work item: W-16984464

@mohammedjamboo-pandora
Copy link
Author

Eg:
Locale: en
Category Id: engravable

As you see in this example since the category name also starts with the same letters as the locale and so the function removeSiteLocaleFromPath actually replaces all instances of locale, in this case en with a blank leaving the category name as gravable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Acknowledged Team has responded to issue BUG P3 git2gus label for bug
Projects
None yet
Development

No branches or pull requests

2 participants