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

Update 1.7.x nginx template ; part 2 #1190

Merged
merged 4 commits into from Oct 15, 2021
Merged

Update 1.7.x nginx template ; part 2 #1190

merged 4 commits into from Oct 15, 2021

Conversation

juangiordana
Copy link
Contributor

Questions Answers
Branch? 1.7.x
Description Simplify back office rewrite rule.
Simplify installation sandbox rewrite rule.
Improve product images rewrite rules.
Improve category images rewrite rules.

Simplify back office `rewrite` rule.

`rewrite` takes a regex to match against the URI, but since we don’t
care about what the URI is we just use a `^` which means “beginning of
string” and thus matches everything.
Simplify installation sandbox `rewrite` rule by removing the second
capture group, since it's not being used.
Improve product images `rewrite` rules.

Consider the following example for easier reading:

```regexp
^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
                       ^/(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
```

* Replace `[0-9]` with `\d`.
* Replace `[_a-zA-Z0-9-]` with `[\w-]`.
* Remove the last capture group `(-[0-9]+)?` as it is already matched
in the previous capture group.
* Properly escape the dot character (`\.`) used in the file
extension: `\.jpg`.
Improve category images `rewrite` rules.

* Unlike product images, we only need to capture what is in the second
level of the URI, so there is no need to have multiple regular
expressions to achieve this task.

Taking into account previous rules, the list of allowed characters is
set to include any alphanumeric characters `\w`, the dot `.`, and the
hyphen `-`, simplifying the whole capture group to: `([\w.-]+)`

* Properly escape the dot character (`\.`) used in the file
extension: `\.jpg`.
@github-actions github-actions bot added the 1.7.x label Oct 14, 2021
@PierreRambaud PierreRambaud merged commit a128dff into PrestaShop:1.7.x Oct 15, 2021
@PierreRambaud
Copy link
Contributor

Thank you @juangiordana

@juangiordana juangiordana deleted the 1.7.x-nginx branch October 15, 2021 17:09
@matks matks changed the title 1.7.x nginx Improve 1.7.x nginx template for docs Oct 20, 2021
@matks matks changed the title Improve 1.7.x nginx template for docs Update 1.7.x nginx template ; part 2 Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants