Skip to content

Commit

Permalink
Use relative url instead of relative path for source map
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Sep 22, 2023
1 parent 6996bab commit f9d316e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/sassc/embedded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f9d316e

Please sign in to comment.