Rename internal url package to avoid overlap with net/url
This commit is contained in:
parent
9f465fd70d
commit
e5d9f2f5a0
23 changed files with 74 additions and 75 deletions
|
@ -19,7 +19,7 @@ import (
|
|||
"miniflux.app/v2/internal/proxy"
|
||||
"miniflux.app/v2/internal/reader/processor"
|
||||
"miniflux.app/v2/internal/storage"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
"miniflux.app/v2/internal/validator"
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (h *handler) getEntryFromBuilder(w http.ResponseWriter, r *http.Request, b
|
|||
proxyOption := config.Opts.ProxyOption()
|
||||
|
||||
for i := range entry.Enclosures {
|
||||
if proxyOption == "all" || proxyOption != "none" && !url.IsHTTPS(entry.Enclosures[i].URL) {
|
||||
if proxyOption == "all" || proxyOption != "none" && !urllib.IsHTTPS(entry.Enclosures[i].URL) {
|
||||
for _, mediaType := range config.Opts.ProxyMediaTypes() {
|
||||
if strings.HasPrefix(entry.Enclosures[i].MimeType, mediaType+"/") {
|
||||
entry.Enclosures[i].URL = proxy.AbsoluteProxifyURL(h.router, r.Host, entry.Enclosures[i].URL)
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
mff "miniflux.app/v2/internal/reader/handler"
|
||||
mfs "miniflux.app/v2/internal/reader/subscription"
|
||||
"miniflux.app/v2/internal/storage"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
"miniflux.app/v2/internal/validator"
|
||||
)
|
||||
|
||||
|
@ -843,7 +843,7 @@ func (h *handler) streamItemContents(w http.ResponseWriter, r *http.Request) {
|
|||
proxyOption := config.Opts.ProxyOption()
|
||||
|
||||
for i := range entry.Enclosures {
|
||||
if proxyOption == "all" || proxyOption != "none" && !url.IsHTTPS(entry.Enclosures[i].URL) {
|
||||
if proxyOption == "all" || proxyOption != "none" && !urllib.IsHTTPS(entry.Enclosures[i].URL) {
|
||||
for _, mediaType := range config.Opts.ProxyMediaTypes() {
|
||||
if strings.HasPrefix(entry.Enclosures[i].MimeType, mediaType+"/") {
|
||||
entry.Enclosures[i].URL = proxy.AbsoluteProxifyURL(h.router, r.Host, entry.Enclosures[i].URL)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
const defaultClientTimeout = 1 * time.Second
|
||||
|
@ -34,7 +34,7 @@ func (c *Client) PushEntry(entry *model.Entry) error {
|
|||
}
|
||||
_, err := net.DialTimeout("tcp", c.baseURL, defaultClientTimeout)
|
||||
if err != nil {
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/notify")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/notify")
|
||||
if err != nil {
|
||||
return fmt.Errorf(`apprise: invalid API endpoint: %v`, err)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Document structure of an Espial document
|
||||
|
@ -42,7 +42,7 @@ func (c *Client) AddEntry(link, title, content, tags string) error {
|
|||
Tags: tags,
|
||||
}
|
||||
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/api/add")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/add")
|
||||
if err != nil {
|
||||
return fmt.Errorf(`espial: invalid API endpoint: %v`, err)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Document structure of a Linkding document
|
||||
|
@ -49,7 +49,7 @@ func (c *Client) AddEntry(title, entryURL string) error {
|
|||
Unread: c.unread,
|
||||
}
|
||||
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/api/bookmarks/")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/bookmarks/")
|
||||
if err != nil {
|
||||
return fmt.Errorf(`linkding: invalid API endpoint: %v`, err)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Document structure of a Nununx Keeper document
|
||||
|
@ -42,7 +42,7 @@ func (c *Client) AddEntry(link, title, content string) error {
|
|||
ContentType: "text/html",
|
||||
}
|
||||
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/v2/documents")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/v2/documents")
|
||||
if err != nil {
|
||||
return fmt.Errorf(`nunux-keeper: invalid API endpoint: %v`, err)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
"miniflux.app/v2/internal/version"
|
||||
)
|
||||
|
||||
|
@ -34,7 +34,7 @@ func (c *Client) AddLink(entryURL, entryTitle string) error {
|
|||
return fmt.Errorf("shaarli: missing base URL or API secret")
|
||||
}
|
||||
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/api/v1/links")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/v1/links")
|
||||
if err != nil {
|
||||
return fmt.Errorf("shaarli: invalid API endpoint: %v", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
"miniflux.app/v2/internal/version"
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ func (c *Client) AddBookmark(entryURL, entryTitle string) error {
|
|||
return fmt.Errorf("shiori: unable to authenticate: %v", err)
|
||||
}
|
||||
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/api/bookmarks")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/bookmarks")
|
||||
if err != nil {
|
||||
return fmt.Errorf("shiori: invalid API endpoint: %v", err)
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func (c *Client) AddBookmark(entryURL, entryTitle string) error {
|
|||
}
|
||||
|
||||
func (c *Client) authenticate() (sessionID string, err error) {
|
||||
apiEndpoint, err := url.JoinBaseURLAndPath(c.baseURL, "/api/login")
|
||||
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/login")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("shiori: invalid API endpoint: %v", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
internal_url "miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Client represents a Wallabag client.
|
||||
|
@ -44,7 +44,7 @@ func (c *Client) AddEntry(link, title, content string) error {
|
|||
}
|
||||
|
||||
func (c *Client) createEntry(accessToken, link, title, content string) error {
|
||||
endpoint, err := internal_url.JoinBaseURLAndPath(c.baseURL, "/api/entries.json")
|
||||
endpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/entries.json")
|
||||
if err != nil {
|
||||
return fmt.Errorf("wallbag: unable to generate entries endpoint: %v", err)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (c *Client) getAccessToken() (string, error) {
|
|||
values.Add("username", c.username)
|
||||
values.Add("password", c.password)
|
||||
|
||||
endpoint, err := internal_url.JoinBaseURLAndPath(c.baseURL, "/oauth/v2/token")
|
||||
endpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/oauth/v2/token")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("wallbag: unable to generate token endpoint: %v", err)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -45,7 +45,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter,
|
|||
case "image":
|
||||
doc.Find("img").Each(func(i int, img *goquery.Selection) {
|
||||
if srcAttrValue, ok := img.Attr("src"); ok {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !url.IsHTTPS(srcAttrValue)) {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !urllib.IsHTTPS(srcAttrValue)) {
|
||||
img.SetAttr("src", proxifyFunction(router, srcAttrValue))
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter,
|
|||
case "audio":
|
||||
doc.Find("audio").Each(func(i int, audio *goquery.Selection) {
|
||||
if srcAttrValue, ok := audio.Attr("src"); ok {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !url.IsHTTPS(srcAttrValue)) {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !urllib.IsHTTPS(srcAttrValue)) {
|
||||
audio.SetAttr("src", proxifyFunction(router, srcAttrValue))
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter,
|
|||
|
||||
doc.Find("audio source").Each(func(i int, sourceElement *goquery.Selection) {
|
||||
if srcAttrValue, ok := sourceElement.Attr("src"); ok {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !url.IsHTTPS(srcAttrValue)) {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !urllib.IsHTTPS(srcAttrValue)) {
|
||||
sourceElement.SetAttr("src", proxifyFunction(router, srcAttrValue))
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter,
|
|||
case "video":
|
||||
doc.Find("video").Each(func(i int, video *goquery.Selection) {
|
||||
if srcAttrValue, ok := video.Attr("src"); ok {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !url.IsHTTPS(srcAttrValue)) {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !urllib.IsHTTPS(srcAttrValue)) {
|
||||
video.SetAttr("src", proxifyFunction(router, srcAttrValue))
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter,
|
|||
|
||||
doc.Find("video source").Each(func(i int, sourceElement *goquery.Selection) {
|
||||
if srcAttrValue, ok := sourceElement.Attr("src"); ok {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !url.IsHTTPS(srcAttrValue)) {
|
||||
if !isDataURL(srcAttrValue) && (proxyOption == "all" || !urllib.IsHTTPS(srcAttrValue)) {
|
||||
sourceElement.SetAttr("src", proxifyFunction(router, srcAttrValue))
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func proxifySourceSet(element *goquery.Selection, router *mux.Router, proxifyFun
|
|||
imageCandidates := sanitizer.ParseSrcSetAttribute(srcsetAttrValue)
|
||||
|
||||
for _, imageCandidate := range imageCandidates {
|
||||
if !isDataURL(imageCandidate.ImageURL) && (proxyOption == "all" || !url.IsHTTPS(imageCandidate.ImageURL)) {
|
||||
if !isDataURL(imageCandidate.ImageURL) && (proxyOption == "all" || !urllib.IsHTTPS(imageCandidate.ImageURL)) {
|
||||
imageCandidate.ImageURL = proxifyFunction(router, imageCandidate.ImageURL)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/reader/date"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Specs: http://web.archive.org/web/20060811235523/http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html
|
||||
|
@ -32,13 +32,13 @@ func (a *atom03Feed) Transform(baseURL string) *model.Feed {
|
|||
feed := new(model.Feed)
|
||||
|
||||
feedURL := a.Links.firstLinkWithRelation("self")
|
||||
feed.FeedURL, err = url.AbsoluteURL(baseURL, feedURL)
|
||||
feed.FeedURL, err = urllib.AbsoluteURL(baseURL, feedURL)
|
||||
if err != nil {
|
||||
feed.FeedURL = feedURL
|
||||
}
|
||||
|
||||
siteURL := a.Links.originalLink()
|
||||
feed.SiteURL, err = url.AbsoluteURL(baseURL, siteURL)
|
||||
feed.SiteURL, err = urllib.AbsoluteURL(baseURL, siteURL)
|
||||
if err != nil {
|
||||
feed.SiteURL = siteURL
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func (a *atom03Feed) Transform(baseURL string) *model.Feed {
|
|||
|
||||
for _, entry := range a.Entries {
|
||||
item := entry.Transform()
|
||||
entryURL, err := url.AbsoluteURL(feed.SiteURL, item.URL)
|
||||
entryURL, err := urllib.AbsoluteURL(feed.SiteURL, item.URL)
|
||||
if err == nil {
|
||||
item.URL = entryURL
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"miniflux.app/v2/internal/reader/date"
|
||||
"miniflux.app/v2/internal/reader/media"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Specs:
|
||||
|
@ -38,13 +38,13 @@ func (a *atom10Feed) Transform(baseURL string) *model.Feed {
|
|||
feed := new(model.Feed)
|
||||
|
||||
feedURL := a.Links.firstLinkWithRelation("self")
|
||||
feed.FeedURL, err = url.AbsoluteURL(baseURL, feedURL)
|
||||
feed.FeedURL, err = urllib.AbsoluteURL(baseURL, feedURL)
|
||||
if err != nil {
|
||||
feed.FeedURL = feedURL
|
||||
}
|
||||
|
||||
siteURL := a.Links.originalLink()
|
||||
feed.SiteURL, err = url.AbsoluteURL(baseURL, siteURL)
|
||||
feed.SiteURL, err = urllib.AbsoluteURL(baseURL, siteURL)
|
||||
if err != nil {
|
||||
feed.SiteURL = siteURL
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (a *atom10Feed) Transform(baseURL string) *model.Feed {
|
|||
|
||||
for _, entry := range a.Entries {
|
||||
item := entry.Transform()
|
||||
entryURL, err := url.AbsoluteURL(feed.SiteURL, item.URL)
|
||||
entryURL, err := urllib.AbsoluteURL(feed.SiteURL, item.URL)
|
||||
if err == nil {
|
||||
item.URL = entryURL
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ func (r *atom10Entry) entryCategories() []string {
|
|||
// We accept only HTML or XHTML documents for now since the intention is to have the same behavior as RSS.
|
||||
func (a *atom10Entry) entryCommentsURL() string {
|
||||
commentsURL := a.Links.firstLinkWithRelationAndType("replies", "text/html", "application/xhtml+xml")
|
||||
if url.IsAbsoluteURL(commentsURL) {
|
||||
if urllib.IsAbsoluteURL(commentsURL) {
|
||||
return commentsURL
|
||||
}
|
||||
return ""
|
||||
|
|
|
@ -7,16 +7,15 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
stdlib_url "net/url"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/crypto"
|
||||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/logger"
|
||||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
@ -24,7 +23,7 @@ import (
|
|||
// FindIcon try to find the website's icon.
|
||||
func FindIcon(websiteURL, iconURL, userAgent string, fetchViaProxy, allowSelfSignedCertificates bool) (*model.Icon, error) {
|
||||
if iconURL == "" {
|
||||
rootURL := url.RootURL(websiteURL)
|
||||
rootURL := urllib.RootURL(websiteURL)
|
||||
logger.Debug("[FindIcon] Trying to find an icon: rootURL=%q websiteURL=%q userAgent=%q", rootURL, websiteURL, userAgent)
|
||||
|
||||
clt := client.NewClientWithConfig(rootURL, config.Opts)
|
||||
|
@ -90,9 +89,9 @@ func parseDocument(websiteURL string, data io.Reader) (string, error) {
|
|||
}
|
||||
|
||||
if iconURL == "" {
|
||||
iconURL = url.RootURL(websiteURL) + "favicon.ico"
|
||||
iconURL = urllib.RootURL(websiteURL) + "favicon.ico"
|
||||
} else {
|
||||
iconURL, _ = url.AbsoluteURL(websiteURL, iconURL)
|
||||
iconURL, _ = urllib.AbsoluteURL(websiteURL, iconURL)
|
||||
}
|
||||
|
||||
return iconURL, nil
|
||||
|
@ -173,7 +172,7 @@ func parseImageDataURL(value string) (*model.Icon, error) {
|
|||
return nil, fmt.Errorf(`icon: invalid data %q (%v)`, value, err)
|
||||
}
|
||||
case "":
|
||||
decodedData, err := stdlib_url.QueryUnescape(data)
|
||||
decodedData, err := url.QueryUnescape(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`icon: unable to decode data URL %q`, value)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/reader/date"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
type jsonFeed struct {
|
||||
|
@ -67,12 +67,12 @@ func (j *jsonFeed) Transform(baseURL string) *model.Feed {
|
|||
|
||||
feed := new(model.Feed)
|
||||
|
||||
feed.FeedURL, err = url.AbsoluteURL(baseURL, j.FeedURL)
|
||||
feed.FeedURL, err = urllib.AbsoluteURL(baseURL, j.FeedURL)
|
||||
if err != nil {
|
||||
feed.FeedURL = j.FeedURL
|
||||
}
|
||||
|
||||
feed.SiteURL, err = url.AbsoluteURL(baseURL, j.SiteURL)
|
||||
feed.SiteURL, err = urllib.AbsoluteURL(baseURL, j.SiteURL)
|
||||
if err != nil {
|
||||
feed.SiteURL = j.SiteURL
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (j *jsonFeed) Transform(baseURL string) *model.Feed {
|
|||
|
||||
for _, item := range j.Items {
|
||||
entry := item.Transform()
|
||||
entryURL, err := url.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
entryURL, err := urllib.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
if err == nil {
|
||||
entry.URL = entryURL
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/reader/date"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
type rdfFeed struct {
|
||||
|
@ -30,7 +30,7 @@ func (r *rdfFeed) Transform(baseURL string) *model.Feed {
|
|||
feed := new(model.Feed)
|
||||
feed.Title = sanitizer.StripTags(r.Title)
|
||||
feed.FeedURL = baseURL
|
||||
feed.SiteURL, err = url.AbsoluteURL(baseURL, r.Link)
|
||||
feed.SiteURL, err = urllib.AbsoluteURL(baseURL, r.Link)
|
||||
if err != nil {
|
||||
feed.SiteURL = r.Link
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (r *rdfFeed) Transform(baseURL string) *model.Feed {
|
|||
if entry.URL == "" {
|
||||
entry.URL = feed.SiteURL
|
||||
} else {
|
||||
entryURL, err := url.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
entryURL, err := urllib.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
if err == nil {
|
||||
entry.URL = entryURL
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"miniflux.app/v2/internal/logger"
|
||||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
type rule struct {
|
||||
|
@ -116,7 +116,7 @@ func applyRule(entryURL string, entry *model.Entry, rule rule) {
|
|||
}
|
||||
|
||||
func getPredefinedRewriteRules(entryURL string) string {
|
||||
urlDomain := url.Domain(entryURL)
|
||||
urlDomain := urllib.Domain(entryURL)
|
||||
for domain, rules := range predefinedRules {
|
||||
if strings.Contains(urlDomain, domain) {
|
||||
return rules
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
"miniflux.app/v2/internal/reader/date"
|
||||
"miniflux.app/v2/internal/reader/media"
|
||||
"miniflux.app/v2/internal/reader/sanitizer"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
// Specs: https://cyber.harvard.edu/rss/rss.html
|
||||
|
@ -42,13 +42,13 @@ func (r *rssFeed) Transform(baseURL string) *model.Feed {
|
|||
feed := new(model.Feed)
|
||||
|
||||
siteURL := r.siteURL()
|
||||
feed.SiteURL, err = url.AbsoluteURL(baseURL, siteURL)
|
||||
feed.SiteURL, err = urllib.AbsoluteURL(baseURL, siteURL)
|
||||
if err != nil {
|
||||
feed.SiteURL = siteURL
|
||||
}
|
||||
|
||||
feedURL := r.feedURL()
|
||||
feed.FeedURL, err = url.AbsoluteURL(baseURL, feedURL)
|
||||
feed.FeedURL, err = urllib.AbsoluteURL(baseURL, feedURL)
|
||||
if err != nil {
|
||||
feed.FeedURL = feedURL
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func (r *rssFeed) Transform(baseURL string) *model.Feed {
|
|||
if entry.URL == "" {
|
||||
entry.URL = feed.SiteURL
|
||||
} else {
|
||||
entryURL, err := url.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
entryURL, err := urllib.AbsoluteURL(feed.SiteURL, entry.URL)
|
||||
if err == nil {
|
||||
entry.URL = entryURL
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ func (r *rssItem) entryCommentsURL() string {
|
|||
commentsURL := strings.TrimSpace(commentLink.Data)
|
||||
// The comments URL is supposed to be absolute (some feeds publishes incorrect comments URL)
|
||||
// See https://cyber.harvard.edu/rss/rss.html#ltcommentsgtSubelementOfLtitemgt
|
||||
if url.IsAbsoluteURL(commentsURL) {
|
||||
if urllib.IsAbsoluteURL(commentsURL) {
|
||||
return commentsURL
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
|
@ -141,7 +141,7 @@ func sanitizeAttributes(baseURL, tagName string, attributes []html.Attribute) ([
|
|||
value = attribute.Val
|
||||
isAnchorLink = true
|
||||
} else {
|
||||
value, err = url.AbsoluteURL(baseURL, value)
|
||||
value, err = urllib.AbsoluteURL(baseURL, value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -350,12 +350,12 @@ func isValidIframeSource(baseURL, src string) bool {
|
|||
}
|
||||
|
||||
// allow iframe from same origin
|
||||
if url.Domain(baseURL) == url.Domain(src) {
|
||||
if urllib.Domain(baseURL) == urllib.Domain(src) {
|
||||
return true
|
||||
}
|
||||
|
||||
// allow iframe from custom invidious instance
|
||||
if config.Opts != nil && config.Opts.InvidiousInstance() == url.Domain(src) {
|
||||
if config.Opts != nil && config.Opts.InvidiousInstance() == urllib.Domain(src) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ func sanitizeSrcsetAttr(baseURL, value string) string {
|
|||
imageCandidates := ParseSrcSetAttribute(value)
|
||||
|
||||
for _, imageCandidate := range imageCandidates {
|
||||
absoluteURL, err := url.AbsoluteURL(baseURL, imageCandidate.ImageURL)
|
||||
absoluteURL, err := urllib.AbsoluteURL(baseURL, imageCandidate.ImageURL)
|
||||
if err == nil {
|
||||
imageCandidate.ImageURL = absoluteURL
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/logger"
|
||||
"miniflux.app/v2/internal/reader/readability"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ func Fetch(websiteURL, rules, userAgent string, cookie string, allowSelfSignedCe
|
|||
}
|
||||
|
||||
// The entry URL could redirect somewhere else.
|
||||
sameSite := url.Domain(websiteURL) == url.Domain(response.EffectiveURL)
|
||||
sameSite := urllib.Domain(websiteURL) == urllib.Domain(response.EffectiveURL)
|
||||
websiteURL = response.EffectiveURL
|
||||
|
||||
if rules == "" {
|
||||
|
@ -87,7 +87,7 @@ func scrapContent(page io.Reader, rules string) (string, error) {
|
|||
}
|
||||
|
||||
func getPredefinedScraperRules(websiteURL string) string {
|
||||
urlDomain := url.Domain(websiteURL)
|
||||
urlDomain := urllib.Domain(websiteURL)
|
||||
|
||||
for domain, rules := range predefinedRules {
|
||||
if strings.Contains(urlDomain, domain) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"miniflux.app/v2/internal/http/client"
|
||||
"miniflux.app/v2/internal/reader/browser"
|
||||
"miniflux.app/v2/internal/reader/parser"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ func parseWebPage(websiteURL string, data io.Reader) (Subscriptions, *errors.Loc
|
|||
|
||||
if feedURL, exists := s.Attr("href"); exists {
|
||||
if feedURL != "" {
|
||||
subscription.URL, _ = url.AbsoluteURL(websiteURL, feedURL)
|
||||
subscription.URL, _ = urllib.AbsoluteURL(websiteURL, feedURL)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,20 +149,20 @@ func tryWellKnownUrls(websiteURL, userAgent, cookie, username, password string)
|
|||
"rss/": "rss",
|
||||
}
|
||||
|
||||
websiteURLRoot := url.RootURL(websiteURL)
|
||||
websiteURLRoot := urllib.RootURL(websiteURL)
|
||||
baseURLs := []string{
|
||||
// Look for knownURLs in the root.
|
||||
websiteURLRoot,
|
||||
}
|
||||
// Look for knownURLs in current subdirectory, such as 'example.com/blog/'.
|
||||
websiteURL, _ = url.AbsoluteURL(websiteURL, "./")
|
||||
websiteURL, _ = urllib.AbsoluteURL(websiteURL, "./")
|
||||
if websiteURL != websiteURLRoot {
|
||||
baseURLs = append(baseURLs, websiteURL)
|
||||
}
|
||||
|
||||
for _, baseURL := range baseURLs {
|
||||
for knownURL, kind := range knownURLs {
|
||||
fullURL, err := url.AbsoluteURL(baseURL, knownURL)
|
||||
fullURL, err := urllib.AbsoluteURL(baseURL, knownURL)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/proxy"
|
||||
"miniflux.app/v2/internal/timezone"
|
||||
"miniflux.app/v2/internal/url"
|
||||
"miniflux.app/v2/internal/urllib"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
@ -65,7 +65,7 @@ func (f *funcMap) Map() template.FuncMap {
|
|||
"proxyURL": func(link string) string {
|
||||
proxyOption := config.Opts.ProxyOption()
|
||||
|
||||
if proxyOption == "all" || (proxyOption != "none" && !url.IsHTTPS(link)) {
|
||||
if proxyOption == "all" || (proxyOption != "none" && !urllib.IsHTTPS(link)) {
|
||||
return proxy.ProxifyURL(f.router, link)
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ func (f *funcMap) Map() template.FuncMap {
|
|||
return false
|
||||
},
|
||||
"domain": func(websiteURL string) string {
|
||||
return url.Domain(websiteURL)
|
||||
return urllib.Domain(websiteURL)
|
||||
},
|
||||
"hasPrefix": func(str, prefix string) bool {
|
||||
return strings.HasPrefix(str, prefix)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package url // import "miniflux.app/v2/internal/url"
|
||||
package urllib // import "miniflux.app/v2/internal/urllib"
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package url // import "miniflux.app/v2/internal/url"
|
||||
package urllib // import "miniflux.app/v2/internal/urllib"
|
||||
|
||||
import "testing"
|
||||
|
Loading…
Reference in a new issue