diff --git a/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs b/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs index d204146..0f49239 100644 --- a/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs +++ b/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Http; @@ -50,6 +51,24 @@ public async Task RefreshAsync_CachesMarkdownAndReferencedImagesForOfflineRender File.Exists(Path.Combine(_appDataDirectory, "docs", "assets", "logo.png")).Should().BeTrue(); } + [Fact] + public async Task RefreshAsync_DownloadsFeedAndAssetsFromMainBranch() + { + var requestedUrls = new List(); + var handler = CreateFeedHandler("# Updates\n\n![Logo](assets/logo.png)", "/docs/assets/logo.png"); + var service = CreateService(new StubHttpMessageHandler(request => + { + requestedUrls.Add(request.RequestUri!.AbsoluteUri); + return handler.Respond(request); + })); + + await service.RefreshAsync(); + + requestedUrls.Should().Equal( + "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/news.md", + "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/assets/logo.png"); + } + [Fact] public async Task GetHtmlAsync_WhenNoFeedIsCached_LoadsRemoteFeed() { @@ -180,6 +199,8 @@ private static StubHttpMessageHandler CreateFeedHandler(string markdown, params private sealed class StubHttpMessageHandler(Func responseFactory) : HttpMessageHandler { protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => - Task.FromResult(responseFactory(request)); + Task.FromResult(Respond(request)); + + public HttpResponseMessage Respond(HttpRequestMessage request) => responseFactory(request); } } diff --git a/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs b/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs index 99a1c73..4c0ec73 100644 --- a/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs +++ b/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs @@ -15,8 +15,8 @@ namespace NoteBookmark.MauiApp.Data; public sealed class NewsFeedService : INewsFeedService { - private const string NewsFeedUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/v-next/docs/news.md"; - private const string NewsAssetsUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/v-next/docs/assets/"; + private const string NewsFeedUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/news.md"; + private const string NewsAssetsUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/assets/"; private const string FallbackHtml = "

Welcome to NoteBookmark! Check back here for product updates.

"; private static readonly Regex HtmlUrlAttributePattern = new( @"(?href|src)=""(?[^""]*)""",