Fix project settings not allowing you to remove links & trim certain project fields (#895)

* Fix project settings not allowing you to remove links

* Trim project fields

Closes #850
This commit is contained in:
Prospector 2023-01-11 10:00:42 -08:00 committed by GitHub
parent cda18fb957
commit de212322e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 13 deletions

View File

@ -153,10 +153,10 @@ export default {
formData.append(
'data',
JSON.stringify({
title: this.name,
title: this.name.trim(),
project_type: projectType.actual,
slug: this.slug,
description: this.description,
description: this.description.trim(),
body: `# Placeholder description
This is your new ${projectType.display}, ${
this.name
@ -235,9 +235,11 @@ Questions? [Join the Modrinth Discord for support!](https://discord.gg/EUHuJHt)`
updatedName() {
if (!this.manualSlug) {
this.slug = this.name
.trim()
.toLowerCase()
.replaceAll(' ', '-')
.replaceAll(/[^a-zA-Z0-9!@$()`.+,_"-]/g, '')
.replaceAll(/--+/gm, '-')
}
},
},

View File

@ -323,13 +323,13 @@ export default {
const data = {}
if (this.name !== this.project.title) {
data.title = this.name
data.title = this.name.trim()
}
if (this.slug !== this.project.slug) {
data.slug = this.slug
data.slug = this.slug.trim()
}
if (this.summary !== this.project.description) {
data.description = this.summary
data.description = this.summary.trim()
}
if (this.clientSide !== this.project.client_side) {
data.client_side = this.clientSide

View File

@ -189,16 +189,17 @@ export default {
const data = {}
if (this.checkDifference(this.issuesUrl, this.project.issues_url)) {
data.issues_url = this.issuesUrl
data.issues_url = this.issuesUrl === '' ? null : this.issuesUrl.trim()
}
if (this.checkDifference(this.sourceUrl, this.project.source_url)) {
data.source_url = this.sourceUrl
data.source_url = this.sourceUrl === '' ? null : this.sourceUrl.trim()
}
if (this.checkDifference(this.wikiUrl, this.project.wiki_url)) {
data.wiki_url = this.wikiUrl
data.wiki_url = this.wikiUrl === '' ? null : this.wikiUrl.trim()
}
if (this.checkDifference(this.discordUrl, this.project.discord_url)) {
data.discord_url = this.discordUrl
data.discord_url =
this.discordUrl === '' ? null : this.discordUrl.trim()
}
const donationLinks = this.donationLinks.filter(
@ -267,11 +268,14 @@ export default {
url: null,
})
},
checkDifference(a, b) {
if (!a && !b) {
checkDifference(newLink, existingLink) {
if (newLink === '' && existingLink !== null) {
return true
}
if (!newLink && !existingLink) {
return false
}
return a !== b
return newLink !== existingLink
},
},
}

View File

@ -323,7 +323,7 @@ export default {
.data
const data = {
user_id: user.id,
user_id: user.id.trim(),
}
await this.$axios.post(