limit query words to list
This commit is contained in:
parent
90cd9915c8
commit
eecd5043f6
@ -1,14 +1,18 @@
|
|||||||
|
const defaultMessage = ' Using word of the day instead.'
|
||||||
|
|
||||||
export function getWordOfTheDay() {
|
export function getWordOfTheDay() {
|
||||||
if (location.search) {
|
if (location.search) {
|
||||||
try {
|
try {
|
||||||
const query = atob(location.search.slice(1))
|
const query = atob(location.search.slice(1))
|
||||||
if (query.length !== 5) {
|
if (query.length !== 5) {
|
||||||
alert('incorrect word length from encoded query.')
|
alert(`Incorrect word length from encoded query. ${defaultMessage}`)
|
||||||
|
} else if (!allWords.includes(query)) {
|
||||||
|
alert(`Encoded query is not in the word list. ${defaultMessage}`)
|
||||||
} else {
|
} else {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('malformed encoded word query.')
|
alert(`Malformed encoded word query. ${defaultMessage}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user