33 lines
777 B
Go
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
|
|
}
|