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 for Key rewrite show invalid example with bucket prefix #441

Closed
JuroOravec opened this issue Apr 9, 2024 · 4 comments
Closed

Docs for Key rewrite show invalid example with bucket prefix #441

JuroOravec opened this issue Apr 9, 2024 · 4 comments
Labels
enhancement New feature or request no-issue-activity no-stale No stale

Comments

@JuroOravec
Copy link

Description

The docs for key rewrite suggest the following:

Given this config:

targets:
  - name: test
    # ...
    keyRewriteList:
      - source: ^/file.html$
        target: /redirected/file.html
    bucket:
      # ...
      prefix: "/folder1"

Then GET /file.html should be rewritten to GET /folder1/redirected/file.html.

HOWEVER, it seems that currently, the source regex MUST account also for the prefix.

So, to redirect from /file.html to /folder1/redirected/file.html, given a bucket prefix /folder1, we need to do:

targets:
  - name: test
    # ...
    keyRewriteList:
      - source: ^/folder1/file.html$
        target: /folder1/redirected/file.html
    bucket:
      # ...
      prefix: "/folder1"

The reason for this is because in the code, currently the logic to get the full path including the prefix is called BEFORE the regex matching logic. See

key := bri.generateStartKey(input.RequestPath)

Describe the solution you'd like

Update the docs to include the correct examples.

@JuroOravec JuroOravec added the enhancement New feature or request label Apr 9, 2024
@oxyno-zeta
Copy link
Owner

Hello,

Thanks for this issue. Yes, documentation is wrong and must be updated.

Oxyno-zeta

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days

@JuroOravec
Copy link
Author

Not stale

@oxyno-zeta
Copy link
Owner

I've fixed the documentation. Thanks for the issue !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no-issue-activity no-stale No stale
Projects
None yet
Development

No branches or pull requests

2 participants