class CKEditor5::Rails::Assets::AssetsImportMap
def initialize(bundle)
def initialize(bundle) @bundle = bundle end
def looks_like_url?(str)
def looks_like_url?(str) uri = URI.parse(str) uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS) rescue URI::InvalidURIError false end
def to_html(nonce: nil)
def to_html(nonce: nil) tag.script( to_json.html_safe, type: 'importmap', nonce: nonce ) end
def to_json(*_args)
def to_json(*_args) import_map = bundle.scripts.each_with_object({}) do |script, map| next if !script.esm? || looks_like_url?(script.import_name) map[script.import_name] = script.url end { imports: import_map }.to_json end