Merge pull request #30 from Bubuni-Team/patch/rss_relative_uri

Fix URL building for feeds with relative URLs
This commit is contained in:
2023-02-15 18:40:35 +03:00
committed by GitHub
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
protected override string ViewableUrl protected override string ViewableUrl
{ {
get => UtmUtility.ApplyParameters(Url, new UtmParameters() get => UtmUtility.ApplyParameters(new Uri(new(Feed.Url), Url), new UtmParameters()
{ {
Source = "telegram", Source = "telegram",
Type = "rss_post", Type = "rss_post",
@@ -9,8 +9,10 @@ namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule
public class UtmUtility public class UtmUtility
{ {
public static string ApplyParameters(string url, UtmParameters parameters) public static string ApplyParameters(string url, UtmParameters parameters)
=> ApplyParameters(new Uri(url), parameters);
public static string ApplyParameters(Uri uri, UtmParameters parameters)
{ {
var uri = new Uri(url);
var query = HttpUtility.ParseQueryString(uri.Query); var query = HttpUtility.ParseQueryString(uri.Query);
SetIfNotNull(query, "utm_source", parameters.Source); SetIfNotNull(query, "utm_source", parameters.Source);