mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
server: torrents: disallow comma in tag
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import {array, boolean, object, record, string} from 'zod';
|
||||
import {noComma} from '../../util/regEx';
|
||||
|
||||
import type {infer as zodInfer} from 'zod';
|
||||
|
||||
const TAG_NO_COMMA_MESSAGE = {
|
||||
message: 'Tag must not contain comma',
|
||||
};
|
||||
|
||||
// POST /api/torrents/add-urls
|
||||
export const addTorrentByURLSchema = object({
|
||||
// URLs to download torrents from
|
||||
@@ -11,7 +16,7 @@ export const addTorrentByURLSchema = object({
|
||||
// Path of destination
|
||||
destination: string().optional(),
|
||||
// Tags
|
||||
tags: array(string()).optional(),
|
||||
tags: array(string().regex(noComma, TAG_NO_COMMA_MESSAGE)).optional(),
|
||||
// Whether destination is the base path [default: false]
|
||||
isBasePath: boolean().optional(),
|
||||
// Whether destination contains completed contents [default: false]
|
||||
@@ -29,7 +34,7 @@ export const addTorrentByFileSchema = object({
|
||||
// Path of destination
|
||||
destination: string().optional(),
|
||||
// Tags
|
||||
tags: array(string()).optional(),
|
||||
tags: array(string().regex(noComma, TAG_NO_COMMA_MESSAGE)).optional(),
|
||||
// Whether destination is the base path [default: false]
|
||||
isBasePath: boolean().optional(),
|
||||
// Whether destination contains completed contents [default: false]
|
||||
@@ -39,3 +44,13 @@ export const addTorrentByFileSchema = object({
|
||||
});
|
||||
|
||||
export type AddTorrentByFileOptions = zodInfer<typeof addTorrentByFileSchema>;
|
||||
|
||||
// PATCH /api/torrents/tags
|
||||
export const setTorrentsTagsSchema = object({
|
||||
// An array of string representing hashes of torrents to operate on
|
||||
hashes: array(string()).nonempty(),
|
||||
// An array of string representing tags
|
||||
tags: array(string().regex(noComma, TAG_NO_COMMA_MESSAGE)),
|
||||
});
|
||||
|
||||
export type SetTorrentsTagsOptions = zodInfer<typeof setTorrentsTagsSchema>;
|
||||
|
||||
@@ -71,14 +71,6 @@ export interface SetTorrentsPriorityOptions {
|
||||
priority: TorrentPriority;
|
||||
}
|
||||
|
||||
// PATCH /api/torrents/tags
|
||||
export interface SetTorrentsTagsOptions {
|
||||
// An array of string representing hashes of torrents to operate on
|
||||
hashes: Array<TorrentProperties['hash']>;
|
||||
// An array of string representing tags
|
||||
tags: TorrentProperties['tags'];
|
||||
}
|
||||
|
||||
// PATCH /api/torrents/trackers
|
||||
export interface SetTorrentsTrackersOptions {
|
||||
// An array of string representing hashes of torrents to operate on
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
const regEx = {
|
||||
url: /^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/,
|
||||
domainName: /(?:https?|udp):\/\/(?:www\.)?([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,18}\b)*(\/[/\d\w.-]*)*(?:[?])*(.+)*/i,
|
||||
cdata: /<!\[CDATA\[(.*?)\]\]>/,
|
||||
} as const;
|
||||
|
||||
export default regEx;
|
||||
export const url = /^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/;
|
||||
export const domainName = /(?:https?|udp):\/\/(?:www\.)?([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,18}\b)*(\/[/\d\w.-]*)*(?:[?])*(.+)*/i;
|
||||
export const cdata = /<!\[CDATA\[(.*?)\]\]>/;
|
||||
export const noComma = /^[^,]+$/;
|
||||
|
||||
Reference in New Issue
Block a user