loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix some code issues

+6 -8
+6 -8
modules/markup/html.go
··· 10 10 "path" 11 11 "path/filepath" 12 12 "regexp" 13 + "slices" 13 14 "strconv" 14 15 "strings" 15 16 "sync" ··· 64 65 validLinksPattern = regexp.MustCompile(`^[a-z][\w-]+://`) 65 66 66 67 // filePreviewPattern matches "http://domain/org/repo/src/commit/COMMIT/filepath#L1-L2" 67 - filePreviewPattern = regexp.MustCompile(`https?://((?:\S+/){3})src/commit/([0-9a-f]{7,64})/(\S+)#(L\d+(?:-L\d+)?)`) 68 + filePreviewPattern = regexp.MustCompile(`https?://((?:\S+/){4,5})src/commit/([0-9a-f]{7,64})/(\S+)#(L\d+(?:-L\d+)?)`) 68 69 69 70 // While this email regex is definitely not perfect and I'm sure you can come up 70 71 // with edge cases, it is still accepted by the CommonMark specification, as ··· 1075 1076 return 1076 1077 } 1077 1078 1078 - // Ensure that every group (m[0]...m[9]) has a match 1079 - for i := 0; i < 10; i++ { 1080 - if m[i] == -1 { 1081 - return 1082 - } 1079 + // Ensure that every group has a match 1080 + if slices.Contains(m, -1) { 1081 + return 1083 1082 } 1084 1083 1085 1084 urlFull := node.Data[m[0]:m[1]] ··· 1089 1088 return 1090 1089 } 1091 1090 1092 - projPath := node.Data[m[2]:m[3]] 1093 - projPath = strings.TrimSuffix(projPath, "/") 1091 + projPath := strings.TrimSuffix(node.Data[m[2]:m[3]], "/") 1094 1092 1095 1093 commitSha := node.Data[m[4]:m[5]] 1096 1094 filePath := node.Data[m[6]:m[7]]