mirror of
				https://github.com/TeamPiped/Piped-Backend.git
				synced 2024-08-14 23:51:41 +00:00 
			
		
		
		
	Merge pull request #540 from TeamPiped/query-length-check
Add check for query length.
This commit is contained in:
		
						commit
						e352d55ce9
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -28,6 +28,9 @@ public class SearchHandlers {
 | 
			
		|||
        if (StringUtils.isEmpty(query))
 | 
			
		||||
            ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is a required parameter"));
 | 
			
		||||
 | 
			
		||||
        if (query.length() > 100)
 | 
			
		||||
            ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is too long"));
 | 
			
		||||
 | 
			
		||||
        return mapper.writeValueAsBytes(YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +41,9 @@ public class SearchHandlers {
 | 
			
		|||
        if (StringUtils.isEmpty(query))
 | 
			
		||||
            ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is a required parameter"));
 | 
			
		||||
 | 
			
		||||
        if (query.length() > 100)
 | 
			
		||||
            ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is too long"));
 | 
			
		||||
 | 
			
		||||
        return mapper.writeValueAsBytes(Arrays.asList(
 | 
			
		||||
                query,
 | 
			
		||||
                YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue