Skip to content

Allow creation of temporary environment using custom-url with empty fragment#487

Merged
philip-maina merged 1 commit intomasterfrom
RF-22799-allow-empty-fragment-in-custom-url
Aug 16, 2023
Merged

Allow creation of temporary environment using custom-url with empty fragment#487
philip-maina merged 1 commit intomasterfrom
RF-22799-allow-empty-fragment-in-custom-url

Conversation

@philip-maina
Copy link
Copy Markdown
Contributor

@philip-maina philip-maina commented Aug 15, 2023

Summary

Prior to this PR, if you passed a custom-url with an empty fragment e.g https://example.com# the # would be stripped off and a temporary environment with url https://example.com would be created instead.

This happens because we parse the custom-url (see here) and parsing urls like so url.Parse(myUrl) in golang has a known issue.

The fix implemented ensures that # is retained in the url even if the fragment is empty.

Related issue: #473

@philip-maina
Copy link
Copy Markdown
Contributor Author

/reviewme @jbarber @magni- @rainforestapp/devs

@marvin-rfbot marvin-rfbot bot added the review label Aug 15, 2023
@marvin-rfbot marvin-rfbot bot requested review from jbarber and magni- August 15, 2023 14:32
runner_test.go Outdated
Comment on lines +285 to +286
if customURLParam != "" {
if client.temporaryEnvironmentURL != customURLParam {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you could also reduce the nesting by putting these 2 if into 1 and use && ?

Copy link
Copy Markdown
Contributor

@sebaherrera07 sebaherrera07 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Did you try this change yourself locally?
Just to be sure that it works as expected.

runner.go Outdated

var environment *rainforest.Environment
environment, err = r.client.CreateTemporaryEnvironment(description, customURL.String(), webhookURL.String())
environment, err = r.client.CreateTemporaryEnvironment(description, customURLParam, webhookURL.String())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also use webhookParam here, since that could be susceptible to the same issue?

@philip-maina philip-maina force-pushed the RF-22799-allow-empty-fragment-in-custom-url branch from f8ddca8 to 4c003ef Compare August 16, 2023 15:13
@philip-maina
Copy link
Copy Markdown
Contributor Author

Looks good to me. Did you try this change yourself locally?
Just to be sure that it works as expected.

Here's the run locally

Screenshot 2023-08-16 at 17 40 02 Screenshot 2023-08-16 at 17 40 35

…y fragment.

Previously, if you passed a custom-url with an empty fragment e.g https://example.com#
the empty fragment would be stripped of and a temporary environment with url
https://example.com would be created. This change ensures that empty fragments
are retained.
@philip-maina philip-maina force-pushed the RF-22799-allow-empty-fragment-in-custom-url branch from 4c003ef to 1212393 Compare August 16, 2023 15:21
@philip-maina philip-maina merged commit 27d7f1d into master Aug 16, 2023
@philip-maina philip-maina deleted the RF-22799-allow-empty-fragment-in-custom-url branch August 16, 2023 15:39
@magni-
Copy link
Copy Markdown
Contributor

magni- commented Aug 16, 2023

@philip-maina Worth a 3.5.1 release?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants