diff --git a/CHANGELOG.md b/CHANGELOG.md index 6744bfed5d..76a34e2240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h * [#1812](https://github.com/Shopify/shopify-cli/pull/1812): App creation with Rails 7 * [#1821](https://github.com/Shopify/shopify-cli/pull/1821): Fix Shopify hosted fonts to load via the local preview URL * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously" +* [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font ## Version 2.7.2 ### Fixed diff --git a/lib/shopify_cli/theme/dev_server/cdn_fonts.rb b/lib/shopify_cli/theme/dev_server/cdn_fonts.rb index f5ddd70990..811e0b7b87 100644 --- a/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +++ b/lib/shopify_cli/theme/dev_server/cdn_fonts.rb @@ -5,7 +5,7 @@ module Theme module DevServer class CdnFonts FONTS_PATH = "/fonts" - FONTS_CDN = "https://fonts.shopifycdn.com/assistant" + FONTS_CDN = "https://fonts.shopifycdn.com" FONTS_REGEX = %r{#{FONTS_CDN}} def initialize(app, theme:) diff --git a/test/shopify-cli/theme/dev_server/cdn_fonts_test.rb b/test/shopify-cli/theme/dev_server/cdn_fonts_test.rb index e00fe03333..1e87e095e0 100644 --- a/test/shopify-cli/theme/dev_server/cdn_fonts_test.rb +++ b/test/shopify-cli/theme/dev_server/cdn_fonts_test.rb @@ -7,7 +7,7 @@ module ShopifyCLI module Theme module DevServer class CdnFontsTest < Minitest::Test - def test_replace_local_fonts_in_reponse_body + def test_replace_local_assistant_n4_font_in_reponse_body original_html = <<~HTML
@@ -18,7 +18,25 @@ def test_replace_local_fonts_in_reponse_body expected_html = <<~HTML - + + + + HTML + assert_equal(expected_html, serve(original_html).body) + end + + def test_replace_local_firasans_n4_font_in_reponse_body + original_html = <<~HTML + + + + + + HTML + expected_html = <<~HTML + + + HTML @@ -36,7 +54,7 @@ def test_replace_local_fonts_on_same_line expected_html = <<~HTML - + HTML @@ -64,7 +82,7 @@ def test_serve_font_from_fonts_cdn }) .to_return(status: 200, body: expected_body, headers: {}) - response = serve(path: "/fonts/font.123.woff2?hmac=456") + response = serve(path: "/fonts/assistant/font.123.woff2?hmac=456") actual_body = response.body assert_equal expected_body, actual_body @@ -78,7 +96,7 @@ def test_404_on_missing_cdn_fonts }) .to_return(status: 404, body: "Not found", headers: {}) - response = serve(path: "/fonts/missing.123.woff2?hmac=456") + response = serve(path: "/fonts/assistant/missing.123.woff2?hmac=456") assert_equal(404, response.status) assert_equal("Not found", response.body)