-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[BREAKING CHANGE] feat: remove notfound.enableRedirect #368
Conversation
@dead-horse, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fengmk2, @atian25 and @popomore to be potential reviewers. |
there's no additional informations we can present in non-production environments, so keep it the same as production environment is more reasonable. |
app/middleware/notfound.js
Outdated
@@ -18,16 +18,11 @@ module.exports = options => { | |||
return; | |||
} | |||
|
|||
if (options.enableRedirect && options.pageUrl) { | |||
if (options.pageUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还要防止死循环,确保 referer 不是自己,免得开发者配置了 options.pageUrl ='/404'
,然后又没有实现 404 页面
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
比较难,例如 referrer 为 http://dev.xxx.com/404
,没法判断它是自己,这个还是交由开发者自己保证吧,开发时会发现的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 pageUrl 是当前站点的,以 /
开头,可以通过判断 this.path
是否等于 pageUrl 来解决的
app/middleware/notfound.js
Outdated
|
||
// notfound handler is unimplemented | ||
if (options.pageUrl && this.path === options.pageUrl) { | ||
this.body = `${htmlTitle}config.notfound.pageUrl(${options.pageUrl}) is unimplemented`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加上了,没有做环境判断的区分,统一返回这个文案了。
app/middleware/notfound.js
Outdated
|
||
// notfound handler is unimplemented | ||
if (options.pageUrl && this.path === options.pageUrl) { | ||
this.body = `${notFoundHtml}config.notfound.pageUrl(${options.pageUrl}) is unimplemented`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加个 p
`${notFoundHtml}
<p><pre><code>config.notfound.pageUrl(${options.pageUrl})</code></pre> is unimplemented</p>`;
Codecov Report
@@ Coverage Diff @@
## master #368 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 28 28
Lines 636 637 +1
=====================================
+ Hits 636 637 +1
Continue to review full report at Codecov.
|
这个配置好像影响不大,就不记录了 |
Checklist
npm test
passesAffected core subsystem(s)
notfound
Description of change
remove
notfound.enableRedirect
, always redirect ifnotfound.pageUrl
present, ensure has the same behavior in different environments.