mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
Fix: check summoner name server side to prevent Firefox error
This commit is contained in:
parent
afd1b0d8f3
commit
1c1dc49c69
4 changed files with 23 additions and 16 deletions
|
|
@ -7,7 +7,7 @@
|
|||
type="text"
|
||||
autofocus
|
||||
class="input w-full px-2 py-4 rounded-lg outline-none pl-8 pr-16 font-bold"
|
||||
>
|
||||
/>
|
||||
<div class="absolute right-0 z-30 vertical-center flex items-center h-full mr-2">
|
||||
<div
|
||||
@click="dropdown = !dropdown"
|
||||
|
|
@ -37,13 +37,12 @@
|
|||
:class="classRegions(index)"
|
||||
class="relative px-4b py-1 text-xs bg-teal-600 hover:bg-teal-500"
|
||||
>
|
||||
<v-icon
|
||||
<v-icon
|
||||
v-if="region === selectedRegion"
|
||||
name="check"
|
||||
name="check"
|
||||
scale="0.7"
|
||||
class="absolute vertical-center offsetIcon"
|
||||
>
|
||||
</v-icon>
|
||||
></v-icon>
|
||||
{{ region }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -86,15 +85,9 @@ export default {
|
|||
}
|
||||
},
|
||||
formSubmit() {
|
||||
const regexNames = new RegExp('^[0-9\\p{L} _\\.]+$', 'u')
|
||||
|
||||
if(regexNames.exec(this.summoner)) {
|
||||
this.$emit('formSubmit', this.summoner.split(' ').join(''), this.selectedRegion.toLowerCase())
|
||||
} else {
|
||||
this.$store.dispatch('notification/add', {
|
||||
type: 'error',
|
||||
message: 'Summoner Name entered is incorrect.'
|
||||
})
|
||||
const search = this.summoner.split(' ').join('')
|
||||
if (search.length) {
|
||||
this.$emit('formSubmit', search, this.selectedRegion.toLowerCase())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,11 @@ export default {
|
|||
} else {
|
||||
this.summonerFound = false
|
||||
this.loading = false
|
||||
|
||||
this.$store.dispatch('notification/add', {
|
||||
type: 'error',
|
||||
message: 'Summoner not found.'
|
||||
})
|
||||
console.log('Summoner not found')
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class JaxRequest {
|
|||
return JSON.parse(resp)
|
||||
|
||||
} catch ({ statusCode, ...rest }) {
|
||||
console.log('error: ' + statusCode, rest)
|
||||
console.log('error: ' + statusCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,21 @@ app.post('/api', async function (req, res) {
|
|||
console.log(req.body.summoner, req.body.region)
|
||||
console.time('all')
|
||||
|
||||
/* Check if the summonerName is correct before fetching Riot API */
|
||||
const regexSummonerName = new RegExp('^[0-9\\p{L} _\\.]+$', 'u')
|
||||
if (!regexSummonerName.exec(req.body.summoner)) {
|
||||
return res.send(null)
|
||||
}
|
||||
|
||||
const finalJSON = {}
|
||||
jax.regionName = req.body.region
|
||||
|
||||
try {
|
||||
const account = await jax.Summoner.summonerName(req.body.summoner)
|
||||
|
||||
// Check if the summoner is found
|
||||
if (!account) return res.send(null)
|
||||
|
||||
finalJSON.account = account
|
||||
|
||||
const ranked = await jax.League.summonerID(account.id)
|
||||
|
|
@ -66,7 +76,6 @@ app.post('/api', async function (req, res) {
|
|||
console.timeEnd('all')
|
||||
} catch (error) {
|
||||
console.log('username not found')
|
||||
console.log(error)
|
||||
res.send(null)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue