Update discourse.ts#518
Conversation
urlencode was only applied to "topicName" causing an issue. Final URL was partially urlencoded, which is wrong. Removed urlencoding hence unnecessary.
There was a problem hiding this comment.
Pull request overview
This PR fixes Discourse topic validation by removing encodeURIComponent from the URL construction so the Discourse topic path is not incorrectly percent-encoded (notably breaking / separators in typical slug/id topic paths).
Changes:
- Remove
encodeURIComponent(topicName)when building the Discourse URL used for theHEADexistence check.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
as suggested by Copilot
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
apps/frontend/src/utils/discourse.ts:19
- Debounce logic clears the previous timeout but never settles the Promise returned by earlier calls. If
validateDiscourseTopicExistsis invoked again beforedelayelapses, the previous Promise remains pending forever, which can leave form validation stuck in anisValidatingstate and leak unresolved Promises. Consider storing the previous call’sresolveand resolving it (e.g., tofalse) when cancelling, or switching to a debounce approach that doesn’t return a fresh unresolved Promise per keystroke (e.g., aborting in-flight fetches withAbortController).
export const validateDiscourseTopicExists = async (topic: string, delay: number = 500): Promise<boolean> => {
return new Promise(resolve => {
if (debounceTimer) {
clearTimeout(debounceTimer);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



urlencode was only applied to "topicName" causing an issue. Final URL was partially urlencoded, which is wrong. Removed urlencoding hence unnecessary.