-
-
Notifications
You must be signed in to change notification settings - Fork 692
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: added support for example short urls #3311
Conversation
Signed-off-by: Aakanksha <[email protected]>
WalkthroughThe changes made in the Changes
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
public/_redirects (2)
73-77
: LGTM! Consider adding a comment for clarity.The new short URL redirections are well-implemented and align with the PR objective. They provide a convenient way to access example AsyncAPI specifications.
Consider adding a brief comment above the SHORT-URL-REDIRECTION section to explain its purpose. For example:
+# Short URL redirections for quick access to AsyncAPI examples # SHORT-URL-REDIRECTION:START /s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301! /s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! # SHORT-URL-REDIRECTION:END
Potential Conflict with New
/s/*
RedirectionThe existing redirection
/s/example
may conflict with the new/s/*
wildcard rule.
public/_redirects
, Line:/s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301!
🔗 Analysis chain
Line range hint
1-77
: Verify no conflicts with existing redirections.The placement of the new short URL redirections at the end of the file is correct. However, it's important to ensure that no existing redirections conflict with the new
/s/*
wildcard rule.Run the following script to check for potential conflicts:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential conflicts with the new /s/* redirection rule # Test: Search for any existing rules that might conflict with /s/* rg '^/s/' public/_redirects | grep -v '^/s/\*' # If the above command returns any results, it indicates a potential conflict # that needs to be addressed.Length of output: 149
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-3311--asyncapi-website.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
public/_redirects (1)
73-77
: LGTM! Consider placement of wildcard redirection.The addition of short URL redirections is well-implemented and aligns with the PR objective. The use of a comment block for easy identification is a good practice.
A minor suggestion:
Consider moving the wildcard redirection
/s/*
above the specific/s/example
redirection. This ensures that more specific rules take precedence over the wildcard rule, following the principle of most specific to least specific ordering in redirection rules.# SHORT-DOC-URL-REDIRECTION:START +/s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! /s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301! -/s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! # SHORT-DOC-URL-REDIRECTION:ENDThis change would prevent any potential conflicts if more specific short URLs are added in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- public/_redirects (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
public/_redirects (1)
Line range hint
1-77
: Overall, the changes look good and achieve the PR objective.The addition of short URL redirections for examples is well-implemented and doesn't interfere with existing redirections. The use of a comment block for easy identification is a good practice. With the minor suggestion for rule ordering, this implementation provides a solid foundation for managing example short URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
public/_redirects (1)
73-77
: LGTM! Consider optimizing rule order.The new redirection rules for short URLs are well-implemented:
- The wildcard rule
/s/*
provides a flexible way to access various examples.- The specific rule for
/s/example
offers a quick link to a common example.For optimal routing, consider swapping the order of these rules:
# SHORT-DOC-URL-REDIRECTION:START -/s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! /s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301! +/s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! # SHORT-DOC-URL-REDIRECTION:ENDThis ensures the specific rule takes precedence over the wildcard rule, maintaining the intended behavior while potentially improving routing efficiency.
@coderabbitai full review |
✅ Actions performedFull review triggered. |
@akshatnema could you please review |
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
public/_redirects (1)
74-77
: Consider adding documentation for short URLs.Since this is a new feature for short URLs, it would be helpful to document:
- The purpose and usage of these short URLs
- Examples of valid short URL patterns
- Guidelines for adding new short URLs
Would you like me to help create documentation for the short URL feature?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
public/_redirects
(1 hunks)
🔇 Additional comments (2)
public/_redirects (2)
73-73
: LGTM: Empty line provides clear section separation.
The empty line helps maintain readability by separating different redirect rule sections.
74-77
: Verify the example URLs are accessible.
Let's ensure that the target URLs for the new redirect rules are valid and accessible.
✅ Verification successful
Both redirect URLs are accessible and valid
The verification results show that both URLs are accessible:
- The example YAML file (
streetlights-mqtt-asyncapi.yml
) returns a 200 status code - The examples directory URL returns a 301 redirect to the correct tree view URL, which is expected and valid
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the target URLs for the new redirect rules are accessible
# Test 1: Check if the example YAML file exists
echo "Checking streetlights-mqtt-asyncapi.yml..."
curl -I https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml
# Test 2: Check if the examples directory exists
echo -e "\nChecking examples directory..."
curl -I https://github.com/asyncapi/spec/blob/master/examples/
Length of output: 10051
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
public/_redirects (1)
74-77
: Consider adding documentation for the short URL feature.Since this is a new feature, it would be helpful to add a comment explaining:
- The purpose of these short URLs
- Examples of how to use them
- What types of examples are available
Example comment:
# SHORT-DOC-URL-REDIRECTION:START +# Short URLs for AsyncAPI examples: +# - /s/example -> Points to the streetlights MQTT example +# - /s/{example-name} -> Points to other examples in the spec repo /s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301! /s/* https://github.com/asyncapi/spec/blob/master/examples/:splat 301! # SHORT-DOC-URL-REDIRECTION:END
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
public/_redirects
(1 hunks)
🔇 Additional comments (1)
public/_redirects (1)
74-77
: LGTM! Correct implementation of short URL redirects.
The implementation looks good with:
- Proper rule ordering (specific before wildcard)
- Appropriate use of 301 permanent redirects
- Correct usage of :splat parameter
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3311 +/- ##
=======================================
Coverage 77.22% 77.22%
=======================================
Files 21 21
Lines 663 663
=======================================
Hits 512 512
Misses 151 151 ☔ View full report in Codecov by Sentry. |
@@ -70,3 +70,8 @@ https://www.asyncapi.io/* https://www.asyncapi.com/:splat 301! | |||
# Additional redirection | |||
/community/meetings /community/events 301! | |||
/cheatsheet https://github.com/asyncapi/website/tree/master/cheatsheet 302! | |||
|
|||
# SHORT-DOC-URL-REDIRECTION:START | |||
/s/example https://github.com/asyncapi/spec/blob/master/examples/streetlights-mqtt-asyncapi.yml 301! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be 302
(temporary redirect), as we might want to change the destination of short URLs. 301
would ask the browser to cache destination URL.
Thanks @aakankshabhende If that level of manual work is fine, @derberg?, let's go ahead with this approach for future short URLs |
/update |
@akshatnema @derberg PTAL |
Looking at the scope of this issue, we might go for another approach, most probably using the headless backend for storing the URL map. This issue could be pushed to the bounty/mentorship program, therefore. |
Description
Added support for example short urls. Fixes #3005
Related issue(s)
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes