Open mbestavros opened 2 months ago
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.
Files | Change Summary |
---|---|
src/background.js | Modified createRedirectRule function to include URL parsing and error handling for instance . |
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! 🐇✨
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.
@libreom anything else needed here?
@libreom Pinging again - any chance this can be pulled in?
I just got free from uni work,will hopefully review this week
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