Skip to content

Commit

Permalink
spec(pages): URLとして使用できる文字を制限 (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Jan 7, 2025
1 parent e1ae455 commit 4f9aee8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/pages/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const paramDef = {
type: 'object',
properties: {
title: { type: 'string' },
name: { type: 'string', minLength: 1 },
name: { type: 'string', minLength: 1, pattern: /^[a-zA-Z0-9_-]+$/.toString().slice(1, -1) },
summary: { type: 'string', nullable: true },
content: { type: 'array', items: {
type: 'object', additionalProperties: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/pages/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const paramDef = {
properties: {
pageId: { type: 'string', format: 'misskey:id' },
title: { type: 'string' },
name: { type: 'string', minLength: 1 },
name: { type: 'string', minLength: 1, pattern: /^[a-zA-Z0-9_-]+$/.toString().slice(1, -1) },
summary: { type: 'string', nullable: true },
content: { type: 'array', items: {
type: 'object', additionalProperties: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/page-editor/page-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts._pages.summary }}</template>
</MkInput>

<MkInput v-model="name">
<MkInput v-model="name" type="text" pattern="^[a-zA-Z0-9_-]+$" autocapitalize="off">
<template #prefix>{{ url }}/@{{ author.username }}/pages/</template>
<template #label>{{ i18n.ts._pages.url }}</template>
</MkInput>
Expand Down Expand Up @@ -158,7 +158,7 @@ function save() {

if (pageId.value) {
options.pageId = pageId.value;
misskeyApi('pages/update', options)
os.apiWithDialog('pages/update', options)
.then(page => {
currentName.value = name.value.trim();
os.alert({
Expand All @@ -167,7 +167,7 @@ function save() {
});
}).catch(onError);
} else {
misskeyApi('pages/create', options)
os.apiWithDialog('pages/create', options)
.then(created => {
pageId.value = created.id;
currentName.value = name.value.trim();
Expand Down

0 comments on commit 4f9aee8

Please sign in to comment.