twitter-text 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/autolink.rb CHANGED
@@ -16,6 +16,10 @@ module Twitter
16
16
  DEFAULT_TARGET = nil
17
17
  # HTML attribute for robot nofollow behavior (default)
18
18
  HTML_ATTR_NO_FOLLOW = " rel=\"nofollow\""
19
+ # Options which should not be passed as HTML attributes
20
+ OPTIONS_NOT_ATTRIBUTES = [:url_class, :list_class, :username_class, :hashtag_class,
21
+ :username_url_base, :list_url_base, :hashtag_url_base,
22
+ :suppress_lists, :suppress_no_follow]
19
23
 
20
24
  HTML_ENTITIES = {
21
25
  '&' => '&',
@@ -101,7 +105,7 @@ module Twitter
101
105
  # this is a screen name
102
106
  chunk = user
103
107
  chunk = yield(chunk) if block_given?
104
- "#{before}#{at}<a class=\"#{options[:url_class]} #{options[:username_class]}\" #{target_tag(options)}href=\"#{html_escape(options[:username_url_base])}#{html_escape(chunk)}\"#{extra_html}>#{html_escape(chunk)}</a>"
108
+ "#{before}#{at}<a class=\"#{options[:url_class]} #{options[:username_class]}\" #{target_tag(options)}href=\"#{html_escape(options[:username_url_base])}#{html_escape(chunk)}\"#{extra_html}>#{html_escape(chunk)}</a>#{slash_listname}"
105
109
  end
106
110
  end
107
111
  end
@@ -143,11 +147,12 @@ module Twitter
143
147
  def auto_link_urls_custom(text, href_options = {})
144
148
  options = href_options.dup
145
149
  options[:rel] = "nofollow" unless options.delete(:suppress_no_follow)
150
+ options[:class] = options.delete(:url_class)
146
151
 
147
152
  text.gsub(Twitter::Regex[:valid_url]) do
148
153
  all, before, url, protocol, domain, path, query_string = $1, $2, $3, $4, $5, $6, $7
149
154
  if !protocol.blank?
150
- html_attrs = tag_options(options.stringify_keys) || ""
155
+ html_attrs = tag_options(options.reject{|k,v| OPTIONS_NOT_ATTRIBUTES.include?(k) }.stringify_keys) || ""
151
156
  "#{before}<a href=\"#{html_escape(url)}\"#{html_attrs}>#{html_escape(url)}</a>"
152
157
  else
153
158
  all
@@ -108,6 +108,7 @@ describe Twitter::Autolink do
108
108
  it "should not be linked" do
109
109
  @autolinked_text = TestAutolink.new.auto_link_usernames_or_lists("hello @jacob/my-list", :suppress_lists => true)
110
110
  @autolinked_text.should_not link_to_list_path('jacob/my-list')
111
+ @autolinked_text.should include('my-list')
111
112
  end
112
113
  end
113
114
 
@@ -524,6 +525,13 @@ describe Twitter::Autolink do
524
525
  auto_linked.should have_autolinked_url('http://twitter.com/#search')
525
526
  end
526
527
 
528
+ it "should not add invalid option in HTML tags" do
529
+ auto_linked = @linker.auto_link("http://twitter.com/ is a URL, not a hashtag", :hashtag_class => 'hashtag_classname')
530
+ auto_linked.should have_autolinked_url('http://twitter.com/')
531
+ auto_linked.should_not include('hashtag_class')
532
+ auto_linked.should_not include('hashtag_classname')
533
+ end
534
+
527
535
  end
528
536
 
529
537
  end
data/twitter-text.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = "twitter-text"
3
- s.version = "1.4.1"
3
+ s.version = "1.4.2"
4
4
  s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle", "Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa"]
5
5
  s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com", "raffi@twitter.com", "jcummins@twitter.com", "niw@niw.at"]
6
6
  s.homepage = "http://twitter.com"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-text
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 1
10
- version: 1.4.1
9
+ - 2
10
+ version: 1.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Sanford