relay pages at /r/... and nip05 pages at /p/...

This commit is contained in:
fiatjaf
2023-07-27 13:00:52 -03:00
parent bb24a43eb2
commit 4e587cf186
4 changed files with 52 additions and 41 deletions

View File

@@ -92,7 +92,7 @@ var kindNIPS = map[int]string{
30078: "78",
}
var urlMatcher = regexp.MustCompile(`^(wss?:\/\/)?[\w-_.]+\.[\w-_.]+(\/[\/\w]*)?$`)
var urlSuffixMatcher = regexp.MustCompile(`[\w-_.]+\.[\w-_.]+(\/[\/\w]*)?$`)
type ClientReference struct {
Name string
@@ -327,13 +327,13 @@ func mdToHTML(md string) string {
func unique(strSlice []string) []string {
keys := make(map[string]bool)
list := []string{}
list := []string{}
for _, entry := range strSlice {
if _, ok := keys[entry]; !ok {
keys[entry] = true
list = append(list, entry)
}
}
if _, ok := keys[entry]; !ok {
keys[entry] = true
list = append(list, entry)
}
}
return list
}
@@ -343,4 +343,4 @@ func trimProtocol(relay string) string {
relay = strings.TrimPrefix(relay, "wss:/") // Some browsers replace upfront '//' with '/'
relay = strings.TrimPrefix(relay, "ws:/") // Some browsers replace upfront '//' with '/'
return relay
}
}