Post-Migrator/services/slowtwitch/url-converter.go
Ross Trottier 93f5c70236 First Test Run Complete
- TODO Thread Post Creation
- TODO Hunt Down Broken Slideshow Links
2024-05-23 07:41:47 -06:00

33 lines
777 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, ",", "")
output = strings.ReplaceAll(output, "%", "%25")
return output
}