Post-Migrator/services/slowtwitch/url-converter.go
2024-05-19 19:35:53 -06:00

32 lines
728 B
Go

package slowtwitch
import (
"strconv"
"strings"
)
func ConvertUrlToCategoryFormat(oldUrl string) string {
output := convert(oldUrl)
return "/" + output + "/index.html"
}
func ConvertPostTitleToPath(title string, id int) string {
output := convert(title)
return output + "_" + strconv.Itoa(id) + ".html"
}
func GetURL(path string) string {
return "https://www.slowtwitch.com" + path
}
func convert(path string) string {
output := strings.ReplaceAll(path, " ", "_")
output = strings.ReplaceAll(output, "$", "_")
output = strings.ReplaceAll(output, "(", "_")
output = strings.ReplaceAll(output, ")", "_")
output = strings.ReplaceAll(output, "?", "")
output = strings.ReplaceAll(output, ",", "")
return output
}