Skip to content

Commit

Permalink
Simplify normalization of the delimiter
Browse files Browse the repository at this point in the history
I found the `split` can take in a regular expression.
  • Loading branch information
vietqhoang committed Oct 24, 2024
1 parent 3eaf7a1 commit e36fe93
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/importmap/packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def pin_options_for_package(package)

return {} if raw_options.blank?

normalized_delimiter_raw_options = raw_options[:pin_options].gsub(/,\s/, ',').split(',')

normalized_delimiter_raw_options.each_with_object({}) do |option, hash|
raw_options[:pin_options].split(/,\s|,/).each_with_object({}) do |option, hash|
match_data = option.match(/^(?<option_name>[^:]*):[\s+]?["']?(?<option_value>.*[^"'])["']?$/)

hash[match_data[:option_name]] = cast_option_value(match_data[:option_value])
Expand Down

0 comments on commit e36fe93

Please sign in to comment.