Skip to content

Commit

Permalink
fix: fix news/videos sanity checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 13, 2021
1 parent 8bc90bf commit a83ca21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/search/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function sanityCheck(options: NewsSearchOptions) {
if (!options.locale || typeof options.locale! !== 'string')
throw new TypeError('Search locale must be a string!');

if (options.time && Object.values(SearchTimeType).includes(options.time))
if (options.time && !Object.values(SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);

if (options.vqd && !/\d-\d+-\d+/.test(options.vqd)) throw new Error(`${options.vqd} is an invalid VQD!`);
Expand Down
4 changes: 2 additions & 2 deletions src/search/videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ function sanityCheck(options: VideoSearchOptions) {
if (!options.locale || typeof options.locale! !== 'string')
throw new TypeError('Search locale must be a string!');

if (options.time && Object.values(SearchTimeType).includes(options.time))
if (options.time && !Object.values(SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);

if (options.definition && Object.values(VideoDefinition).includes(options.definition))
if (options.definition && !Object.values(VideoDefinition).includes(options.definition))
throw new TypeError(`${options.definition} is an invalid video definition!`);

if (options.duration && !Object.values(VideoDuration).includes(options.duration))
Expand Down

0 comments on commit a83ca21

Please sign in to comment.