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

Docs: regex+replacement hints for URL rewriting #2802

Merged
merged 6 commits into from
Feb 7, 2018

Conversation

djeeg
Copy link
Contributor

@djeeg djeeg commented Feb 3, 2018

What does this PR do?

Documentation - hints for regex replacement

Motivation

Related to #2796

More

  • Added/updated documentation

Additional Notes

Not sure if you would want the extra link to the Go Playground for testing regex/replacements

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution 👍

@@ -120,6 +120,14 @@ To redirect an entrypoint rewriting the URL.
!!! note
Please note that `regex` and `replacement` do not have to be set in the `redirect` structure if an entrypoint is defined for the redirection (they will not be used in this case).

`regex` and `replacement` follow the rules as per [matchers](/basics/#matchers)
Copy link
Member

Choose a reason for hiding this comment

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

This is false, because in matchers we use goriila/mux regex, it's not the same syntax.

Could you remove this sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh thats interesting, have added your extra comment about how they are different

@@ -120,6 +120,14 @@ To redirect an entrypoint rewriting the URL.
!!! note
Please note that `regex` and `replacement` do not have to be set in the `redirect` structure if an entrypoint is defined for the redirection (they will not be used in this case).

`regex` and `replacement` follow the rules as per [matchers](/basics/#matchers)

Specifically the `replacement` rule uses [Go Regexp.ReplaceAllString](https://golang.org/pkg/regexp/#Regexp.ReplaceAllString)
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


Specifically the `replacement` rule uses [Go Regexp.ReplaceAllString](https://golang.org/pkg/regexp/#Regexp.ReplaceAllString)

Care should be taken when defining replacement expand variables; `$1x` is equivalent to `${1x}`, not `${1}x` [see Regexp.Expand](https://golang.org/pkg/regexp/#Regexp.Expand)
Copy link
Member

@ldez ldez Feb 3, 2018

Choose a reason for hiding this comment

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

could you replace the ; by :

And replace [see Regexp.Expand] by see [Regexp.Expand]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, plus added your Regex101 example from the original issue (missed that you had added that as I only saw the first github email notification)

@@ -1,4 +1,4 @@
# Entry Points Definition
# Entry Points Definition
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any change on this line, could you restore the previous state of this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldnt see where this was injected in dev tools, have tweaked via github to remove

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

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

LGTM

@djeeg djeeg requested a review from a team as a code owner February 7, 2018 10:24
@ldez ldez changed the base branch from master to v1.5 February 7, 2018 10:24
@ldez ldez removed the bot/no-merge label Feb 7, 2018
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

5 participants