-
Notifications
You must be signed in to change notification settings - Fork 1
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
usernameに@を含められるように修正 #300
Conversation
ウォークスルーこの変更では、 変更点
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
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.
Files selected (2)
- src/app/(menu)/(public)/[username]/page.tsx (2)
- src/app/(menu)/(public)/[username]/posts/[postId]/page.tsx (1)
Review comments generated (3)
- Review: 3
- LGTM: 0
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
const username = decodeURIComponent(params.username); | ||
if (post.author.username !== username) { |
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.
この変更は、ユーザー名に@
が含まれている場合でも正しく動作するようになりました。ただし、decodeURIComponent
関数はエラーをスローする可能性があります。URLが不適切にエンコードされている場合や、無効なパーセントエンコーディングが含まれている場合などです。これらのエラーを適切に処理するために、try...catch
ブロックを使用してください。
- const username = decodeURIComponent(params.username);
+ let username;
+ try {
+ username = decodeURIComponent(params.username);
+ } catch (e) {
+ // 適切なエラーハンドリングを行います。
+ console.error(e);
+ return;
+ }
const username = decodeURIComponent(params.username); | ||
const user = await getUser(username); |
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.
decodeURIComponent
関数は、不正なURIコンポーネントを渡された場合にエラーをスローします。そのため、この関数の呼び出しはtry-catchブロックで囲むべきです。これにより、ユーザーが不正なパラメータを送信した場合でもアプリケーションがクラッシュすることを防げます。
- const username = decodeURIComponent(params.username);
+ let username;
+ try {
+ username = decodeURIComponent(params.username);
+ } catch (e) {
+ // 不正なパラメータを処理するための適切なエラーハンドリングを追加します。
+ return {};
+ }
const user = await getUser(username);
const username = decodeURIComponent(params.username); | ||
const user = await getUser(username); |
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.
同様に、decodeURIComponent
関数の呼び出しはtry-catchブロックで囲むべきです。これにより、ユーザーが不正なパラメータを送信した場合でもアプリケーションがクラッシュすることを防げます。
- const username = decodeURIComponent(params.username);
+ let username;
+ try {
+ username = decodeURIComponent(params.username);
+ } catch (e) {
+ // 不正なパラメータを処理するための適切なエラーハンドリングを追加します。
+ notFound();
+ return;
+ }
const user = await getUser(username);
Issue
変更内容
/test@example.com
のようなパスパラメータを受け取り可能に確認方法
@を含むユーザーIDのユーザーページを開けること
Summary by CodeRabbit