From f9d316e6245d204c7e8734d30e26b409df70f4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 22 Sep 2023 01:46:27 -0700 Subject: [PATCH] Use relative url instead of relative path for source map --- lib/sassc/embedded.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/sassc/embedded.rb b/lib/sassc/embedded.rb index e67560e..690eaa8 100644 --- a/lib/sassc/embedded.rb +++ b/lib/sassc/embedded.rb @@ -49,7 +49,7 @@ def render source_mapping_url = if source_map_embed? "data:application/json;base64,#{[@source_map].pack('m0')}" else - URL.file_urls_to_relative_path(source_map_file_url, url) + URL.file_urls_to_relative_url(source_map_file_url, url) end css += "\n/*# sourceMappingURL=#{source_mapping_url} */" end @@ -79,10 +79,10 @@ def source_map url = URL.parse(source_map_file_url || file_url) data = JSON.parse(@source_map) - data['file'] = URL.file_urls_to_relative_path(output_url, url) if output_url + data['file'] = URL.file_urls_to_relative_url(output_url, url) if output_url data['sources'].map! do |source| if source.start_with?(Protocol::FILE) - URL.file_urls_to_relative_path(source, url) + URL.file_urls_to_relative_url(source, url) else source end @@ -568,8 +568,12 @@ def unescape(str) PARSER.unescape(str) end + def file_urls_to_relative_url(url, from_url) + URL.parse(url).route_from(from_url).to_s + end + def file_urls_to_relative_path(url, from_url) - URL.unescape(URL.parse(url).route_from(from_url).to_s) + URL.unescape(file_urls_to_relative_url(url, from_url)) end def file_url_to_path(url)