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

Refactor collapseLeadingSlashes function for simplicity and readability #183

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Ayoub-Mabrouk
Copy link
Contributor

Replaced the old implementation of collapseLeadingSlashes, which iterated over each character, with a more concise and efficient version using a regular expression. The new version uses
eplace() to collapse leading slashes into a single slash and handles empty strings by returning '/'. This update improves code readability and leverages modern JavaScript string methods.

Replaced the manual loop with `padStart` to simplify the code and improve readability. This aligns with modern JavaScript practices, making the function more concise and easier to maintain. No functional changesjust a cleaner, more efficient approach to padding numbers with leading zeros.
Replaced the old implementation of collapseLeadingSlashes, which iterated over each character, with a more concise and efficient version using a regular expression. The new version uses 
eplace() to collapse leading slashes into a single slash and handles empty strings by returning '/'. This update improves code readability and leverages modern JavaScript string methods.
Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Ayoub-Mabrouk! ❤️

Can you lint the code?

Replaced the old implementation of collapseLeadingSlashes, which iterated over each character, with a more concise and efficient version using a regular expression. The new version uses 
eplace() to collapse leading slashes into a single slash and handles empty strings by returning '/'. This update improves code readability and leverages modern JavaScript string methods.
Replaced the manual loop with `padStart` to simplify the code and improve readability. This aligns with modern JavaScript practices, making the function more concise and easier to maintain. No functional changesjust a cleaner, more efficient approach to padding numbers with leading zeros.
…e manual loop with padStart to simplify the code and improve readability. This aligns with modern JavaScript practices, making the function more concise and easier to maintain. No functional changesjust a cleaner, more efficient approach to padding numbers with leading zeros.
Replaced the old implementation of collapseLeadingSlashes, which iterated over each character, with a more concise and efficient version using a regular expression. The new version uses 
eplace() to collapse leading slashes into a single slash and handles empty strings by returning '/'. This update improves code readability and leverages modern JavaScript string methods.
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.

2 participants