Azure / Azure/static-web-apps-cli

Support for trailingSlash config

Đang mở
#418 4 bình luận 2 reaction 1 người được giao Được @lcartel nhận Xem trên GitHub
complexity: hours good first issue priority: high (P0) scope: msha scope: rules engine status: need e2e tests status: release-blocker type: enhancement type: RFC
Ngôn ngữ chính
TypeScript
Star
668
Fork
156
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Is your feature request related to a problem? Please describe.**
staticwebappconfig.json will include a property to configure trailingSlash behavior:

The following normalization and redirect rules will apply for each of the available configurations:

### Always

When setting trailingSlashes to `always`, all requests that don't include a trailing slash will be redirected to a trailing slash URL. For example, `/contact` will be redirected to `/contact/`.

```json
"trailingSlash": "always"
```

| Requests to... | returns... | with the status... | and path... |
|--|--|--|--|
| _/about_ | The _/about/index.html_ file | `301` | _/about/_ |
| _/about/_ | The _/about/index.html_ file | `200` | _/about/_ |
| _/about/index.html_ | The _/about/index.html_ file | `301` | _/about/_ |
| _/contact_ | The _/contact.html_ file | `301` | _/contact/_ |
| _/contact/_ | The _/contact.html_ file | `200` | _/contact/_ |
| _/contact.html_ | The _/contact.html_ file | `301` | _/contact/_ |

### Never

When setting trailingSlash to `never`, all requests ending in a trailing slash will be redirected to a non-trailing slash URL. For example, `/contact/` will be redirected to `/contact`.

```json
"trailingSlash": "never"
```

| Requests to... | returns... | with the status... | and path... |
|--|--|--|--|
| _/about_ | The _/about/index.html_ file | `200` | _/about_ |
| _/about/_ | The _/about/index.html_ file | `301` | _/about_ |
| _/about/index.html_ | The _/about/index.html_ file | `301` | _/about_ |
| _/contact_ | The _/contact.html_ file | `200` | _/contact_ |
| _/contact/_ | The _/contact.html_ file | `301` | _/contact_ |
| _/contact.html_ | The _/contact.html_ file | `301` | _/contact_ |

### Auto

When setting trailingSlash to `auto`, all requests to folders will be redirected to a URL with a trailing slash. All requests to files will be redirected to a non-trailing slash URL.

```json
"trailingSlash": "auto"
```

| Requests to... | returns... | with the status... | and path... |
|--|--|--|--|
| _/about_ | The _/about/index.html_ file | `301` | _/about/_ |
| _/about/_ | The _/about/index.html_ file | `200` | _/about/_ |
| _/about/index.html_ | The _/about/index.html_ file | `301` | _/about/_ |
| _/contact_ | The _/contact.html_ file | `200` | _/contact_ |
| _/contact/_ | The _/contact.html_ file | `301` | _/contact_ |
| _/contact.html_ | The _/contact.html_ file | `301` | _/contact_ |

By default, when the trailingSlash configuration is omitted, Azure Static Web Apps will apply the following rules:

| Requests to... | returns... | with the status... | and path... |
|--|--|--|--|
| _/about_ | The _/about/index.html_ file | `200` | _/about_ |
| _/about/_ | The _/about/index.html_ file | `200` | _/about/_ |
| _/about/index.html_ | The _/about/index.html_ file | `200` | _/about/index.html_ |
| _/contact_ | The _/contact.html_ file | `200` | _/contact_ |
| _/contact/_ | The _/contact.html_ file | `301` | _/contact_ |
| _/contact.html_ | The _/contact.html_ file | `200` | _/contact.html_ |

**Describe the solution you'd like**
Static Web Apps CLI should apply the same redirect and normalization rules.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.