Fix some printfs, clean regexes, switch to fuzzy matching for search

This commit is contained in:
comp500
2019-11-01 15:46:50 +00:00
parent 33c93f3ac3
commit 5ba9ff5c73
8 changed files with 97 additions and 71 deletions

View File

@@ -23,9 +23,9 @@ func init() {
}
var fileIDRegexes = [...]*regexp.Regexp{
regexp.MustCompile("^https?:\\/\\/minecraft\\.curseforge\\.com\\/projects\\/(.+)\\/files\\/(\\d+)"),
regexp.MustCompile("^https?:\\/\\/(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/(.+)\\/files\\/(\\d+)"),
regexp.MustCompile("^https?:\\/\\/(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/(.+)\\/download\\/(\\d+)"),
regexp.MustCompile("^https?://minecraft\\.curseforge\\.com/projects/(.+)/files/(\\d+)"),
regexp.MustCompile("^https?://(?:www\\.)?curseforge\\.com/minecraft/mc-mods/(.+)/files/(\\d+)"),
regexp.MustCompile("^https?://(?:www\\.)?curseforge\\.com/minecraft/mc-mods/(.+)/download/(\\d+)"),
}
func getFileIDsFromString(mod string) (bool, int, int, error) {
@@ -44,8 +44,8 @@ func getFileIDsFromString(mod string) (bool, int, int, error) {
}
var modSlugRegexes = [...]*regexp.Regexp{
regexp.MustCompile("^https?:\\/\\/minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)"),
regexp.MustCompile("^https?:\\/\\/(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/([^\\/]+)"),
regexp.MustCompile("^https?://minecraft\\.curseforge\\.com/projects/([^/]+)"),
regexp.MustCompile("^https?://(?:www\\.)?curseforge\\.com/minecraft/mc-mods/([^/]+)"),
// Exact slug matcher
regexp.MustCompile("^[a-z][\\da-z\\-_]{0,127}$"),
}