Skip to content

Update discourse.ts#518

Merged
victhorbi merged 4 commits into
mainfrom
victhorbi-patch-urlencode-discourse-topic
Mar 9, 2026
Merged

Update discourse.ts#518
victhorbi merged 4 commits into
mainfrom
victhorbi-patch-urlencode-discourse-topic

Conversation

@victhorbi
Copy link
Copy Markdown
Collaborator

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

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 the HEAD existence check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/frontend/src/utils/discourse.ts Outdated
Agilulfo1820
Agilulfo1820 previously approved these changes Mar 2, 2026
Comment thread apps/frontend/src/utils/discourse.ts Outdated
as suggested by Copilot
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 2, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 validateDiscourseTopicExists is invoked again before delay elapses, the previous Promise remains pending forever, which can leave form validation stuck in an isValidating state and leak unresolved Promises. Consider storing the previous call’s resolve and resolving it (e.g., to false) when cancelling, or switching to a debounce approach that doesn’t return a fresh unresolved Promise per keystroke (e.g., aborting in-flight fetches with AbortController).
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.

Comment thread apps/frontend/src/utils/discourse.ts
@victhorbi victhorbi merged commit 78b60d4 into main Mar 9, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants