Sha256: 2ce278b25bb4737e5a70a66a0157107317d323c8fefd825b5abf554ab3455fa6
Contents?: true
Size: 706 Bytes
Versions: 4
Compression:
Stored size: 706 Bytes
Contents
# frozen_string_literal: true module JsDependency module Extractor class ExtractScriptTag # @param [String] str def initialize(str) @str = str end # @return [Array<String>] def call str = @str scripts = str.gsub(%r{<script>(.+)</script>}m).with_object([]) do |_, list| list << Regexp.last_match(1) end scripts += str.gsub(%r{<script.+src=".+">(.+)</script>}m).with_object([]) do |_, list| list << Regexp.last_match(1) end scripts.uniq.sort.join("\n") end # @param [String] str # @return [String] def self.call(str) new(str).call end end end end
Version data entries
4 entries across 4 versions & 1 rubygems