Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add optional full URL handling for custom instances #39

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

Open
mbestavros wants to merge 1 commit into pritkr:main
base: main
Choose a base branch
Loading
from mbestavros:main

Conversation

@mbestavros
Copy link

@mbestavros mbestavros commented Sep 11, 2024

This PR adds some additional parsing logic to allow custom instance fields to be full URLs.

The primary benefit from the additional parsing is that custom instances can specify properties they couldn't before - specifically, port numbers and plain HTTP, if desired. This is particularly handy for users self-hosting their own frontends.

If the custom instance field is not populated with a valid URL, the extension will fall back to the old behavior - in other words, it should be fully backwards compatible.

cc: @libreom

libreom reacted with heart emoji
Copy link

coderabbitai bot commented Sep 11, 2024
edited
Loading

Walkthrough

The changes involve modifications to the createRedirectRule function within the updateRules function in src/background.js. The instance parameter is now parsed to extract the protocol, hostname, and port from a URL format, with added error handling to ensure robustness. The construction of the transform object for redirect properties has been updated to use the parsed URL components dynamically, enhancing flexibility in the generated redirection rules.

Changes

Files Change Summary
src/background.js Modified createRedirectRule function to include URL parsing and error handling for instance.

Poem

In the code where rabbits play,
Redirects now find their way.
With protocols parsed, oh what a sight,
Flexibility hops, taking flight!
Error handling, a wise little trick,
Ensures our rules are clever and quick! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f0b691f and d76dd52.

Files selected for processing (1)
  • src/background.js (2 hunks)
Additional comments not posted (2)
src/background.js (2)

416-425: Excellent enhancements to the createRedirectRule function! LGTM.

The changes introduce several key improvements:

  1. URL parsing:

    • Allows the instance parameter to accept full URLs, providing more flexibility to users.
    • Extracts the protocol, hostname, and port from the URL, enabling support for custom protocols and ports.
    • Provides a fallback to "https" protocol and null port if parsing fails, ensuring graceful handling of invalid URLs.
  2. Dynamic transform object:

    • Constructs the transform object dynamically based on the parsed URL components.
    • Enables the function to generate redirect rules that match the provided URL format.
    • Maintains backward compatibility by defaulting to "https" and null port when parsing fails.
  3. Error handling:

    • The try-catch block ensures that parsing failures are caught and handled gracefully.
    • Prevents the function from throwing errors and breaking the redirect rules.

These enhancements greatly improve the flexibility, robustness, and user experience of the createRedirectRule function. Great job!


438-438: Correct usage of the transform object.

The transform object is properly used in the returned redirect rule to specify the scheme, host, and port for the redirect. This is consistent with the changes made to construct the transform object dynamically based on the parsed URL components.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Signed-off-by: Mark Bestavros <markbest@bu.edu>
Copy link
Author

@libreom anything else needed here?

Copy link
Author

@libreom Pinging again - any chance this can be pulled in?

Copy link
Collaborator

libreom commented Nov 20, 2024

I just got free from uni work,will hopefully review this week

mbestavros and ThunderHen reacted with heart emoji

Copy link
Author

@libreom Quick ping again - would love to have this functionality in the official release 😄

libreom and ThunderHen reacted with heart emoji

Copy link
Author

@libreom I hate to be a bother, any chance you could take a look/merge this soon? If you need testing anecdata, I've been running this change for months and it's worked perfectly fine 🙂

Copy link
Collaborator

libreom commented Feb 24, 2025

I love your patience, I'll review and merge within next 2 days hopefully

Copy link
Author

@libreom Gentle reminder again 😉

Copy link
Author

@libreom Checking in again - any chance this can be pulled in?

Copy link
Author

@libreom I don't like being a nag, but it's been nearly nine months since I opened this PR. I'd really like to get it merged and released to the Chrome Web Store if possible.

I understand you may be busy - do you need help with maintainership duties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /