diff --git a/fedilogue.go b/fedilogue.go index 0e12385..3fc2b35 100644 --- a/fedilogue.go +++ b/fedilogue.go @@ -34,6 +34,7 @@ func main() { spaceReg = regexp.MustCompile(`[\s\t\.]+`) removeHTMLReg = regexp.MustCompile(`<\/?\s*br\s*>`) re = regexp.MustCompile("^https?://([^/]*)/(.*)$") + matchurl = regexp.MustCompile("http?s://[\\w\\-]+\\.[\\w\\-]+\\S*") for _, endpoint := range settings.Autostart { logInfo.Print("Autostarting " + endpoint) diff --git a/retrieve.go b/retrieve.go index 5597a25..07edce3 100644 --- a/retrieve.go +++ b/retrieve.go @@ -18,6 +18,7 @@ var p *bluemonday.Policy var spaceReg *regexp.Regexp var removeHTMLReg *regexp.Regexp var re *regexp.Regexp +var matchurl *regexp.Regexp type ImageType struct { // Type string `json:"type"` @@ -146,6 +147,7 @@ func check_post(uri string) (PostJson, error) { postjson.normalized = removeHTMLReg.ReplaceAllString(postjson.Content, " ") postjson.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(postjson.normalized))) + postjson.normalized = matchurl.ReplaceAllString(postjson.normalized, "") postjson.normalized = spaceReg.ReplaceAllString(postjson.normalized, " ") _, err = pool.Exec(context.Background(), "INSERT INTO posts (id, inreplyto, published, summary, content, normalized, attributedto, posthash, instance) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)", postjson.ID, postjson.InReplyTo, postjson.Published, postjson.Summary, postjson.Content, postjson.normalized, postjson.AttributedTo, postjson.posthash, postjson.instance)