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

Exclusions option to filter urls #148

Merged
merged 8 commits into from
Oct 24, 2024

Conversation

chapmandu
Copy link
Contributor

@chapmandu chapmandu commented Oct 16, 2024

This pull request enhances the Sitemapper class by adding support for URL exclusion patterns and includes corresponding unit tests to ensure the new functionality works as expected.

Use Case

To enable filtering unwanted sitemap indexes/urls. Example: https://www.slamcity.com/sitemap.xml contains the same urls but in 20+ languages. Attempting to parse this sitemap as is causes Error fetching sitemap: Maximum call stack size exceeded

Enhancements to Sitemapper class:

  • Added a new exclusions option to the constructor, allowing users to specify an array of regex patterns to exclude certain URLs. (src/assets/sitemapper.js) [1] [2]
  • Implemented a new isExcluded method to check if a URL matches any of the exclusion patterns. (src/assets/sitemapper.js)
  • Updated the URL filtering logic in the Sitemapper class to use the isExcluded method, ensuring excluded URLs are filtered out during sitemap processing. (src/assets/sitemapper.js) [1] [2]

Unit tests for exclusions:

  • Added unit tests for the new exclusions option to verify that URLs matching the exclusion patterns are correctly filtered out. (src/tests/test.js)
  • Added unit tests for the isExcluded method to ensure it handles various scenarios, including no exclusions, matching and non-matching URLs, complex regex patterns, and case sensitivity. (src/tests/test.js)

@pull-request-size pull-request-size bot added size/M and removed size/L labels Oct 16, 2024
@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 16, 2024
@chapmandu chapmandu marked this pull request as ready for review October 17, 2024 06:21
Copy link
Owner

@seantomburke seantomburke left a comment

Choose a reason for hiding this comment

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

Appreciate the test section!

@seantomburke seantomburke merged commit 2b0894a into seantomburke:master Oct 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants