mirror of
				https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
				synced 2025-11-01 07:21:09 +08:00 
			
		
		
		
	fix: 简单限制一下订阅/组合订阅的名称(不可包含 "/" )
This commit is contained in:
		
							parent
							
								
									14648d6401
								
							
						
					
					
						commit
						a4ff32331a
					
				| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "sub-store", | ||||
|   "version": "2.14.78", | ||||
|   "version": "2.14.79", | ||||
|   "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", | ||||
|   "main": "src/main.js", | ||||
|   "scripts": { | ||||
|  | ||||
| @ -22,6 +22,16 @@ export default function register($app) { | ||||
| function createCollection(req, res) { | ||||
|     const collection = req.body; | ||||
|     $.info(`正在创建组合订阅:${collection.name}`); | ||||
|     if (/\//.test(collection.name)) { | ||||
|         failed( | ||||
|             res, | ||||
|             new RequestInvalidError( | ||||
|                 'INVALID_NAME', | ||||
|                 `Collection ${collection.name} is invalid`, | ||||
|             ), | ||||
|         ); | ||||
|         return; | ||||
|     } | ||||
|     const allCols = $.read(COLLECTIONS_KEY); | ||||
|     if (findByName(allCols, collection.name)) { | ||||
|         failed( | ||||
| @ -31,6 +41,7 @@ function createCollection(req, res) { | ||||
|                 `Collection ${collection.name} already exists.`, | ||||
|             ), | ||||
|         ); | ||||
|         return; | ||||
|     } | ||||
|     allCols.push(collection); | ||||
|     $.write(allCols, COLLECTIONS_KEY); | ||||
|  | ||||
| @ -96,6 +96,16 @@ async function getFlowInfo(req, res) { | ||||
| function createSubscription(req, res) { | ||||
|     const sub = req.body; | ||||
|     $.info(`正在创建订阅: ${sub.name}`); | ||||
|     if (/\//.test(sub.name)) { | ||||
|         failed( | ||||
|             res, | ||||
|             new RequestInvalidError( | ||||
|                 'INVALID_NAME', | ||||
|                 `Subscription ${sub.name} is invalid`, | ||||
|             ), | ||||
|         ); | ||||
|         return; | ||||
|     } | ||||
|     const allSubs = $.read(SUBS_KEY); | ||||
|     if (findByName(allSubs, sub.name)) { | ||||
|         failed( | ||||
| @ -105,6 +115,7 @@ function createSubscription(req, res) { | ||||
|                 `Subscription ${sub.name} already exists.`, | ||||
|             ), | ||||
|         ); | ||||
|         return; | ||||
|     } | ||||
|     allSubs.push(sub); | ||||
|     $.write(allSubs, SUBS_KEY); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 xream
						xream