MCPcopy Index your code
hub / github.com/writefreely/writefreely / extractImages

Function extractImages

posts.go:1742–1764  ·  view source on GitHub ↗
(content string)

Source from the content-addressed store, hash-verified

1740}
1741
1742func extractImages(content string) []string {
1743 matches := extract.ExtractUrls(content)
1744 urls := map[string]bool{}
1745 for i := range matches {
1746 uRaw := matches[i].Text
1747 // Parse the extracted text so we can examine the path
1748 u, err := url.Parse(uRaw)
1749 if err != nil {
1750 continue
1751 }
1752 // Ensure the path looks like it leads to an image file
1753 if !imageURLRegex.MatchString(u.Path) {
1754 continue
1755 }
1756 urls[uRaw] = true
1757 }
1758
1759 resURLs := make([]string, 0)
1760 for k := range urls {
1761 resURLs = append(resURLs, k)
1762 }
1763 return resURLs
1764}

Callers 2

handleViewPostFunction · 0.85
extractImagesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected