twitter-text 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/autolink.rb +1 -1
- data/lib/regex.rb +10 -3
- data/spec/regex_spec.rb +21 -1
- metadata +3 -3
data/Rakefile
CHANGED
|
@@ -9,7 +9,7 @@ require 'digest'
|
|
|
9
9
|
|
|
10
10
|
spec = Gem::Specification.new do |s|
|
|
11
11
|
s.name = "twitter-text"
|
|
12
|
-
s.version = "1.1.
|
|
12
|
+
s.version = "1.1.5"
|
|
13
13
|
s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle", "Raffi Krikorian"]
|
|
14
14
|
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com", "raffi@twitter.com"]
|
|
15
15
|
s.homepage = "http://twitter.com"
|
data/lib/autolink.rb
CHANGED
data/lib/regex.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Twitter
|
|
4
4
|
# A collection of regular expressions for parsing Tweet text. The regular expression
|
|
@@ -31,7 +31,12 @@ module Twitter
|
|
|
31
31
|
REGEXEN[:extract_mentions] = /(^|[^a-zA-Z0-9_])#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})(?=(.|$))/o
|
|
32
32
|
REGEXEN[:extract_reply] = /^(?:#{REGEXEN[:spaces]})*#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})/o
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
major, minor, patch = RUBY_VERSION.split(/\./)
|
|
35
|
+
if major.to_i >= 1 && minor.to_i >= 9
|
|
36
|
+
REGEXEN[:list_name] = /^[a-zA-Z\u0080-\u00ff].{0,79}$/
|
|
37
|
+
else
|
|
38
|
+
REGEXEN[:list_name] = /^[a-zA-Z\x80-\xff].{0,79}$/
|
|
39
|
+
end
|
|
35
40
|
|
|
36
41
|
# Latin accented characters (subtracted 0xD7 from the range, it's a confusable multiplication sign. Looks like "x")
|
|
37
42
|
LATIN_ACCENTS = [(0xc0..0xd6).to_a, (0xd8..0xf6).to_a, (0xf8..0xff).to_a].flatten.pack('U*').freeze
|
|
@@ -51,9 +56,11 @@ module Twitter
|
|
|
51
56
|
# 1. Used in Wikipedia URLs like /Primer_(film)
|
|
52
57
|
# 2. Used in IIS sessions like /S(dfd346)/
|
|
53
58
|
REGEXEN[:wikipedia_disambiguation] = /(?:\([^\)]+\))/i
|
|
59
|
+
# Allow @ in a url, but only in the middle. Catch things like http://example.com/@user
|
|
54
60
|
REGEXEN[:valid_url_path_chars] = /(?:
|
|
55
61
|
#{REGEXEN[:wikipedia_disambiguation]}|
|
|
56
|
-
[
|
|
62
|
+
@[^\/]+\/|
|
|
63
|
+
[\.\,]?[a-z0-9!\*';:=\+\$\/%#\[\]\-_,~]
|
|
57
64
|
)/ix
|
|
58
65
|
# Valid end-of-path chracters (so /foo. does not gobble the period).
|
|
59
66
|
# 1. Allow =&# for empty URL parameters and other URL-join artifacts
|
data/spec/regex_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#encoding:
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
|
|
4
4
|
describe "Twitter::Regex regular expressions" do
|
|
@@ -21,4 +21,24 @@ describe "Twitter::Regex regular expressions" do
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
describe "matching List names" do
|
|
25
|
+
it "should match if less than 25 characters" do
|
|
26
|
+
name = "Shuffleboard Community"
|
|
27
|
+
name.length.should < 25
|
|
28
|
+
name.should match(Twitter::Regex::REGEXEN[:list_name])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should not match if greater than 25 characters" do
|
|
32
|
+
name = "Most Glorious Shady Meadows Shuffleboard Community"
|
|
33
|
+
name.length.should > 25
|
|
34
|
+
name.should match(Twitter::Regex[:list_name])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should match Japense names less than 25 characters" do
|
|
38
|
+
name = CGI.unescape("%E4%B9%97")
|
|
39
|
+
name.length.should < 25
|
|
40
|
+
name.should match(Twitter::Regex[:list_name])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
24
44
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 1
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
version: 1.1.
|
|
8
|
+
- 5
|
|
9
|
+
version: 1.1.5
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Matt Sanford
|
|
@@ -18,7 +18,7 @@ autorequire: ""
|
|
|
18
18
|
bindir: bin
|
|
19
19
|
cert_chain: []
|
|
20
20
|
|
|
21
|
-
date: 2010-07-
|
|
21
|
+
date: 2010-07-22 00:00:00 -07:00
|
|
22
22
|
default_executable:
|
|
23
23
|
dependencies:
|
|
24
24
|
- !ruby/object:Gem::Dependency
|