mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
refactor(subscription): replace a regex with strings.CutPrefix
This commit is contained in:
parent
dcfe0a7d94
commit
7a394b0bf8
1 changed files with 2 additions and 7 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"miniflux.app/v2/internal/config"
|
"miniflux.app/v2/internal/config"
|
||||||
|
@ -24,10 +23,6 @@ import (
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
youtubeChannelRegex = regexp.MustCompile(`channel/(.*)$`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type SubscriptionFinder struct {
|
type SubscriptionFinder struct {
|
||||||
requestBuilder *fetcher.RequestBuilder
|
requestBuilder *fetcher.RequestBuilder
|
||||||
feedDownloaded bool
|
feedDownloaded bool
|
||||||
|
@ -300,8 +295,8 @@ func (f *SubscriptionFinder) FindSubscriptionsFromYouTubeChannelPage(websiteURL
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches := youtubeChannelRegex.FindStringSubmatch(decodedUrl.Path); len(matches) == 2 {
|
if _, after, found := strings.Cut(decodedUrl.Path, "channel/"); found {
|
||||||
feedURL := fmt.Sprintf(`https://www.youtube.com/feeds/videos.xml?channel_id=%s`, matches[1])
|
feedURL := "https://www.youtube.com/feeds/videos.xml?channel_id=" + after
|
||||||
return Subscriptions{NewSubscription(websiteURL, feedURL, parser.FormatAtom)}, nil
|
return Subscriptions{NewSubscription(websiteURL, feedURL, parser.FormatAtom)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue