Skip to content

Commit

Permalink
Refactor duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Jul 7, 2024
1 parent f674b0e commit ba0c6b8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/sassc/embedded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,26 +323,23 @@ def canonicalize(url, context)

if containing_url.include?('?')
canonical_url = Uri.path_to_file_url(File.absolute_path(path, parent_dir))
if @importer_results.key?(canonical_url)
@importer_result = @importer_results.delete(canonical_url)
canonical_url
else
unless @importer_results.key?(canonical_url)
@file_url = resolve_file_url(path, parent_dir, context.from_import)
nil
return
end
else
imports = @importer.imports(path, parent_path)
imports = [SassC::Importer::Import.new(path)] if imports.nil?
imports = [imports] unless imports.is_a?(Array)
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, containing_url)
if @importer_results.key?(canonical_url)
@importer_result = @importer_results.delete(canonical_url)
canonical_url
else
unless @importer_results.key?(canonical_url)
@file_url = canonical_url
nil
return
end
end

@importer_result = @importer_results.delete(canonical_url)
canonical_url
end

def load(_canonical_url)
Expand Down

0 comments on commit ba0c6b8

Please sign in to comment.