diff options
| author | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2018-12-26 18:32:16 +0900 |
|---|---|---|
| committer | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-12-26 18:32:16 +0900 |
| commit | 4662641feb66197737e7ff63dcb168c739b97054 (patch) | |
| tree | a4c73f69fa113f826118074833887296a2f8aea3 /src/server/web | |
| parent | Fix #3715 (#3752) (diff) | |
| download | sharkey-4662641feb66197737e7ff63dcb168c739b97054.tar.gz sharkey-4662641feb66197737e7ff63dcb168c739b97054.tar.bz2 sharkey-4662641feb66197737e7ff63dcb168c739b97054.zip | |
Fix #3745 (#3746)
Diffstat (limited to 'src/server/web')
| -rw-r--r-- | src/server/web/index.ts | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/server/web/index.ts b/src/server/web/index.ts index f2a40c01f7..c5c6f21c92 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -8,6 +8,7 @@ import * as Router from 'koa-router'; import * as send from 'koa-send'; import * as favicon from 'koa-favicon'; import * as views from 'koa-views'; +import { ObjectID } from 'mongodb'; import docs from './docs'; import packFeed from './feed'; @@ -149,18 +150,22 @@ router.get('/@:user', async (ctx, next) => { // Note router.get('/notes/:note', async ctx => { - const note = await Note.findOne({ _id: ctx.params.note }); + if (ObjectID.isValid(ctx.params.note)) { + const note = await Note.findOne({ _id: ctx.params.note }); - if (note != null) { - const _note = await packNote(note); - await ctx.render('note', { - note: _note, - summary: getNoteSummary(_note) - }); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); - } else { - ctx.status = 404; + if (note) { + const _note = await packNote(note); + await ctx.render('note', { + note: _note, + summary: getNoteSummary(_note) + }); + ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); + + return; + } } + + ctx.status = 404; }); //#endregion |