From 51a032b544cd27dacdab93d524d27d48ff70b599 Mon Sep 17 00:00:00 2001 From: Julien Poitrin Date: Thu, 26 Jan 2023 11:02:19 +0100 Subject: [PATCH] Do not `replace_asset_urls` in font bodies --- CHANGELOG.md | 3 +++ lib/shopify_cli/theme/dev_server/local_assets.rb | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7d1655e63..adce62d316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h ## [Unreleased] +### Fixed +* [#2721](https://github.com/Shopify/shopify-cli/pull/2721): Do not `replace_asset_urls` in font bodies + ## Version 2.34.0 - 2023-01-11 ### Added diff --git a/lib/shopify_cli/theme/dev_server/local_assets.rb b/lib/shopify_cli/theme/dev_server/local_assets.rb index ec4d9a4daa..94e9528627 100644 --- a/lib/shopify_cli/theme/dev_server/local_assets.rb +++ b/lib/shopify_cli/theme/dev_server/local_assets.rb @@ -29,13 +29,14 @@ def initialize(ctx, app, target) end def call(env) - if env["PATH_INFO"].start_with?("/assets") + path_info = env["PATH_INFO"] + if path_info.start_with?("/assets") # Serve from disk - serve_file(env["PATH_INFO"]) + serve_file(path_info) else # Proxy the request, and replace the URLs in the response status, headers, body = @app.call(env) - body = replace_asset_urls(body) + body = replace_asset_urls(body) unless path_info.start_with?("/fonts") [status, headers, body] end end @@ -53,6 +54,10 @@ def replace_asset_urls(body) end [replaced_body] + rescue ArgumentError => error + return [body.join] if error.message.include?("invalid byte sequence") + + raise error end def serve_fail(status, body)