fixed broken elements due to api changes

This commit is contained in:
cnachtigall1991
2021-10-17 19:52:12 +02:00
parent 123f78cb21
commit 6310295795
10 changed files with 228 additions and 69 deletions

View File

@@ -73,28 +73,52 @@ export default {
const id64Pattern = /^\d{17}$/
const vanityPattern = /^[A-Za-z0-9-_]{3,32}$/
store.state.id64 = ''
store.state.vanityUrl = ''
store.commit({
type: 'changeVanityUrl',
id: ''
})
store.commit({
type: 'changeId64',
id: ''
})
if (data.searchInput !== '') {
if (id64Pattern.test(input)) {
store.state.id64 = input
store.commit({
type: 'changeId64',
id: input
})
} else if (input.match(customUrlPattern)) {
store.state.vanityUrl = input.split('/')[4].split('?')[0]
store.commit({
type: 'changeVanityUrl',
id: input.split('/')[4].split('?')[0]
})
} else if (input.match(profileUrlPattern)) {
const tmp = input.split('/')[4].split('?')[0]
if (id64Pattern.test(tmp)) {
store.state.id64 = tmp
store.commit({
type: 'changeId64',
id: tmp
})
}
} else {
store.state.vanityUrl = input
store.commit({
type: 'changeVanityUrl',
id: input
})
}
if (vanityPattern.test(store.state.vanityUrl)) {
store.state.vanityUrl = input
store.commit({
type: 'changeVanityUrl',
id: input
})
} else {
data.error = 'Only alphanumeric symbols, "_", and "-", between 3-32 characters'
store.state.vanityUrl = ''
store.commit({
type: 'changeVanityUrl',
id: ''
})
}
if (store.state.id64 !== '' || store.state.vanityUrl !== '') {
@@ -104,6 +128,11 @@ export default {
data.searchInput = ''
document.activeElement.blur()
store.commit({
type: 'changePlayerDetails',
data: resData
})
if (store.state.vanityUrl) {
closeNav()
GoToPlayer(store.state.vanityUrl)
@@ -115,8 +144,13 @@ export default {
} else if (res === 404) {
data.searchInput = ''
data.error = `${resData} - Try again`
// TODO: needs 404
} else if (res === 502) {
data.searchInput = ''
data.error = 'Server not available'
} else {
console.log(res, resData)
// TODO: needs 404
}
}