Encourage redirect after POST (#80) · w3c/web-share-target@0d9d25f
ewilligers
·
2019-04-16
·
via Recent Commits to web-share-target:main
This repository was archived by the owner on Jun 30, 2026. It is now read-only.
| Original file line number | Diff line number | Diff line change |
|---|
@@ -200,8 +200,8 @@ <h2>
|
200 | 200 | event.respondWith((async () => { |
201 | 201 | const formData = await event.request.formData(); |
202 | 202 | const link = formData.get('link') || ''; |
203 | | - saveBookmark(link); |
204 | | - return new Response('Bookmark saved: ' + link); |
| 203 | +const responseUrl = await saveBookmark(link); |
| 204 | + return Response.redirect(responseUrl, 303); |
205 | 205 | })()); |
206 | 206 | }); |
207 | 207 | </pre> |
@@ -268,6 +268,12 @@ <h2>
|
268 | 268 | <code>url</code> with a short link to fit into the message size. |
269 | 269 | </li> |
270 | 270 | </ul> |
| 271 | +<p> |
| 272 | + As with HTML forms, replying to a POST request with a |
| 273 | +<a data-cite="!RFC7231#section-6.4.4">303 See Other</a> redirect |
| 274 | + is highly recommended, as it avoids the POST being submitted a |
| 275 | + second time if the user requests a page refresh. |
| 276 | +</p> |
271 | 277 | </section> |
272 | 278 | <section data-link-for="WebAppManifest"> |
273 | 279 | <h2> |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。