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

fix: remove extra symbols from fragment URLs #3634

Merged
merged 7 commits into from
Feb 1, 2025

Conversation

Shriya-Chauhan
Copy link
Contributor

@Shriya-Chauhan Shriya-Chauhan commented Jan 31, 2025

Description
This PR fixes an issue where commas (,) in fragment URLs cause broken links.

2025-01-31.15-28-34.mp4

Related issue(s)
fixes #3633

Summary by CodeRabbit

Summary by CodeRabbit

  • Style
    • Updated table of contents slug generation to remove additional special characters during processing, enhancing the cleanliness of slugs.

Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request updates the regular expression used in the slugWithATag property within the tocItems mapping of the TOC component in the components/TOC.tsx file. The regex pattern is expanded to include additional special characters, specifically @, #, $, %, ^, &, *, (, ), [, ], {, }, ,, and ;, ensuring these characters are removed when generating slugs for table of contents items.

Changes

File Change Summary
components/TOC.tsx Updated regex pattern from /[<>?!:'."\/=]/gito/[<>?!:'."\\/=@#$%^&*()[\]{}+,;]/gi, expanding characters stripped for slug generation.

Assessment against linked issues

Objective Addressed Explanation
URL should automatically replace commas in fragments with hyphens (#3633)

Possibly related PRs

  • fix: toc links in the blogs #3562: The changes in the main PR, which modify the regular expression for the slugWithATag property, are related to the updates in the retrieved PR that conditionally use this property for TOC navigation.

Suggested reviewers

  • derberg
  • akshatnema
  • magicmatatjahu

Poem

🐰 A Regex Rabbit's Delight
Commas dance, now stripped from sight,
In slugs that wind through pages bright,
A tiny change, a character's plight,
Making links clean and URLs just right!
Hop, hop, hurray! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71d8c1f and f4e47f2.

📒 Files selected for processing (1)
  • components/TOC.tsx (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 31, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f4e47f2
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/679dc1b4d3f18a00084f2b8d
😎 Deploy Preview https://deploy-preview-3634--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bca2a91 and ded1ec5.

📒 Files selected for processing (1)
  • components/TOC.tsx (1 hunks)
🧰 Additional context used
🪛 ESLint
components/TOC.tsx

[error] 42-42: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 42-42: Delete ········

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project
components/TOC.tsx

[error] 42-42: Trailing spaces not allowed


[error] 42-42: Delete trailing whitespace

⏰ Context from checks skipped due to timeout of 180000ms (4)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Lighthouse CI
🔇 Additional comments (1)
components/TOC.tsx (1)

42-42: LGTM! The change effectively addresses the broken links issue.

Adding comma to the regex pattern ensures that commas are stripped from fragment URLs, preventing link breakage. This is a focused fix that directly addresses the issue described in PR #3633.

🧰 Tools
🪛 ESLint

[error] 42-42: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 42-42: Delete ········

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[error] 42-42: Trailing spaces not allowed


[error] 42-42: Delete trailing whitespace

components/TOC.tsx Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8423e96) to head (f4e47f2).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3634   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          732       732           
=========================================
  Hits           732       732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shriya-Chauhan
Copy link
Contributor Author

@anshgoyalevil Kindly review

components/TOC.tsx Outdated Show resolved Hide resolved
anshgoyalevil
anshgoyalevil previously approved these changes Feb 1, 2025
Copy link
Member

@anshgoyalevil anshgoyalevil left a comment

Choose a reason for hiding this comment

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

Thanks

components/TOC.tsx Outdated Show resolved Hide resolved
@anshgoyalevil
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit f0e6ca9 into asyncapi:master Feb 1, 2025
21 of 23 checks passed
@anshgoyalevil anshgoyalevil changed the title fix: remove commas from fragment URLs fix: remove extra symbols from fragment URLs Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Comma in Fragment of URL Is Not Being Replaced, Causing Broken Links
3 participants