Add validation for <lastmod>, <priority>, and <changefreq> fields in XMLSitemap #195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented validation for : Ensured the date follows the W3C date format (YYYY-MM-DD) or the full W3C datetime format (YYYY-MM-DDThh:mm:ss±hh:mm or YYYY-MM-DDThh:mm:ssZ). Added a regex check to validate the date format.
Implemented validation for : Restricted the values to the allowed set: {"always", "hourly", "daily", "weekly", "monthly", "yearly", "never"}. Added a function to check the validity of the
changefreq
value.Implemented validation for : Ensured the priority is a float value between 0.0 and 1.0. Added a function to validate the
priority
value.Updated
add_url
method:lastmod
,changefreq
, andpriority
parameters.Added regex patterns and validation functions:
W3C_DATE_REGEX
: Matches the date format YYYY-MM-DD.W3C_DATETIME_REGEX
: Matches the full datetime format YYYY-MM-DDThh:mm:ss±hh:mm or YYYY-MM-DDThh:mm:ssZ.is_valid_date
: Validates whether a given date string matches the W3C date or datetime format.is_valid_changefreq
: Checks ifchangefreq
is one of the allowed values.is_valid_priority
: Checks ifpriority
is a float between 0.0 and 1.0.Logging:
lastmod
,changefreq
, andpriority
values when they are encountered in theadd_url
method.These changes ensure that only correctly formatted values are included in the sitemap, enhancing the robustness and compliance of the generated XML sitemaps with the standard protocols.