chore: minor code quality improvements#49
Merged
ruibaby merged 1 commit intohalo-dev:mainfrom Apr 27, 2026
Merged
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
- Replace String.replaceAll() with String.replace() in UrlUtils.escapeSitemapUrl() for literal string substitutions; replaceAll() compiles a regex pattern on every call which is unnecessary overhead for plain string replacement - Set Content-Type to text/xml;charset=UTF-8 in the sitemap endpoint to make the charset explicit instead of relying on client-side inference - Return HTTP 204 No Content when the sitemap is empty rather than serving an empty body with 200 OK Made-with: Cursor
bedcc55 to
ad2b9b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Three small independent improvements:
UrlUtils.escapeSitemapUrl(): Replace all fivereplaceAll()calls withreplace().replaceAll()compiles a regex pattern on every invocation even for literal strings;replace()does a plain string search and is both faster and clearer in intent.SitemapPluginConfig— Content-Type charset: The sitemap response Content-Type wastext/xmlwith no charset declaration. Per RFC 7303, XML served astext/*should declare the encoding explicitly. Changed totext/xml;charset=UTF-8so clients do not need to guess or rely on the XML declaration inside the document.SitemapPluginConfig— empty sitemap handling: When the lister returns an empty result, the previous code would return HTTP 200 with a blank body. Added.filter(!blank)+.switchIfEmpty(noContent())so an empty sitemap returns HTTP 204 instead, which is more semantically correct and avoids clients trying to parse an empty body as XML.Test plan
/sitemap.xmlresponse includesContent-Type: text/xml;charset=UTF-8header/sitemap.xmlreturns 204 instead of 200 with empty bodyMade with Cursor