Remove numbers at the start of slugs when converting to mod ID (#897)

* Remove numbers at the start of slugs when converting to mod ID

* If mod id is all digits, replace with project ID
This commit is contained in:
Prospector 2023-01-11 12:49:13 -08:00 committed by GitHub
parent b690e3d149
commit 7536322e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -376,9 +376,12 @@ export const createDataPackVersion = async function (
? version.version_number
: `1-${version.version_number}`
const targetStartingDigitsRegex = /^(\d+)(\D+)$/g
const newSlug = `${project.slug
.replace('-', '_')
.replace(/\W/g, '')
.replace(targetStartingDigitsRegex, '$2')
.replace(/^(\d+)$/g, project.id.replace(targetStartingDigitsRegex, '$2'))
.substring(0, 63)}_mr`
const iconPath = `${project.slug}_pack.png`