link_to_url

in rb/lib/twitter-text/autolink.rb [247:277]


      def link_to_url(entity, chars, options = {})
        url = entity[:url]

        href = if options[:link_url_block]
                 options[:link_url_block].call(url)
               else
                 url
               end

        # NOTE auto link to urls do not use any default values and options
        # like url_class but use suppress_no_follow.
        html_attrs = options[:html_attrs].dup
        html_attrs[:class] = options[:url_class] if options.key?(:url_class)

        # add target attribute only if :url_target is specified
        html_attrs[:target] = options[:url_target] if options.key?(:url_target)

        url_entities = url_entities_hash(options[:url_entities])

        # use entity from urlEntities if available
        url_entity = url_entities[url] || entity
        link_text = if url_entity[:display_url]
                      html_attrs[:title] ||= url_entity[:expanded_url]
                      link_url_with_entity(url_entity, options)
                    else
                      html_escape(url)
                    end

        link_to_text(entity, link_text, href, html_attrs, options)
      end