Loose compare in sanitize

This commit is contained in:
patrickkfkan 2021-01-24 02:41:26 +08:00
parent 178059dc19
commit ced83e862a

View File

@ -31,7 +31,7 @@ async function sanitizeDiscoverParams(params) {
return getDiscoverOptions().then( options => {
const getOptionValue = (optArr, value) => {
if (value !== undefined && optArr) {
const opt = optArr.find( o => o.value === value );
const opt = optArr.find( o => o.value == value );
if (opt) {
return opt.value;
}
@ -54,7 +54,7 @@ async function sanitizeDiscoverParams(params) {
if (subgenreOptions) { // false if genre is 'all'
sanitized.subgenre = getOptionValue(subgenreOptions, params.subgenre);
}
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre === subgenreOptions[0].value;
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre == subgenreOptions[0].value;
if (timeAllowed) {
sanitized.time = getOptionValue(options.times, params.time);
}