postrank-uri 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,7 +134,7 @@ module PostRank
134
134
  end
135
135
 
136
136
  def hash(uri, opts = {})
137
- Digest::MD5.hexdigest(opts[:skip_clean] ? uri : clean(uri))
137
+ Digest::MD5.hexdigest(opts[:clean] == false ? uri : clean(uri))
138
138
  end
139
139
 
140
140
  def normalize(uri)
@@ -161,6 +161,10 @@ module PostRank
161
161
  u.path = $1
162
162
  end
163
163
 
164
+ if u.host =~ /tumblr\.com$/
165
+ u.path = u.path.gsub(/[^\/]+$/, '')
166
+ end
167
+
164
168
  u
165
169
  end
166
170
 
@@ -1,5 +1,5 @@
1
1
  module PostRank
2
2
  module URI
3
- VERSION = "1.0.9"
3
+ VERSION = "1.0.10"
4
4
  end
5
5
  end
@@ -132,6 +132,12 @@ describe PostRank::URI do
132
132
  end
133
133
  end
134
134
 
135
+ context "tumblr" do
136
+ it "should strip slug" do
137
+ c('http://test.tumblr.com/post/4533459403/some-text').should == 'http://test.tumblr.com/post/4533459403/'
138
+ end
139
+ end
140
+
135
141
  context "embedded links" do
136
142
  it "should extract embedded redirects from Google News" do
137
143
  u = c('http://news.google.com/news/url?sa=t&fd=R&&url=http://www.ctv.ca/CTVNews/Politics/20110111/')
@@ -167,6 +173,8 @@ describe PostRank::URI do
167
173
 
168
174
  c('igvita.com?id=<>').should == 'http://igvita.com/?id=%3C%3E'
169
175
  c('igvita.com?id="').should == 'http://igvita.com/?id=%22'
176
+
177
+ c('test.tumblr.com/post/23223/text-stub').should == 'http://test.tumblr.com/post/23223'
170
178
  end
171
179
 
172
180
  it "should clean host specific parameters" do
@@ -193,8 +201,8 @@ describe PostRank::URI do
193
201
  it "should not clean the URI if requested" do
194
202
  hash = '55fae8910d312b7878a3201ed653b881'
195
203
 
196
- h('http://everburning.com/feed/post/1', :skip_clean => true).should == hash
197
- h('everburning.com/feed/post/1', :skip_clean => true).should_not == hash
204
+ h('http://everburning.com/feed/post/1', :clean => false).should == hash
205
+ h('everburning.com/feed/post/1', :clean => false).should_not == hash
198
206
  end
199
207
  end
200
208
 
@@ -273,30 +281,31 @@ describe PostRank::URI do
273
281
  end
274
282
  end
275
283
 
276
- context 'domain extraction' do
277
- url_list = {"http://alex.pages.example.com" => "example.com",
278
- "alex.pages.example.com" => "example.com",
279
- "http://example.com/2011/04/01/blah" => "example.com",
280
- "http://example.com" => "example.com",
281
- "example.com" => "example.com",
282
- "ExampLe.com" => "example.com",
283
- "ExampLe.com:3000" => "example.com",
284
- "http://alex.pages.example.COM" => "example.com",
285
- "http://www.example.ag.it/2011/04/01/blah" => "example.ag.it",
286
- "ftp://www.example.com/2011/04/01/blah" => nil,
287
- "http://com" => nil,
288
- "http://alex.pages.examplecom" => nil,
289
- "example" => nil,
290
- "http://127.0.0.1" => nil,
291
- "localhost" => nil
292
- }
293
-
294
- url_list.each_pair do |url, expected_result|
295
- it "should extract #{expected_result.inspect} from #{url}" do
296
- u = PostRank::URI.clean(url, :raw => true)
297
- u.domain.should == expected_result
298
- end
299
- end
284
+ context "domain extraction" do
285
+ url_list = {
286
+ "http://alex.pages.example.com" => "example.com",
287
+ "alex.pages.example.com" => "example.com",
288
+ "http://example.com/2011/04/01/blah" => "example.com",
289
+ "http://example.com" => "example.com",
290
+ "example.com" => "example.com",
291
+ "ExampLe.com" => "example.com",
292
+ "ExampLe.com:3000" => "example.com",
293
+ "http://alex.pages.example.COM" => "example.com",
294
+ "http://www.example.ag.it/2011/04/01/blah" => "example.ag.it",
295
+ "ftp://www.example.com/2011/04/01/blah" => nil,
296
+ "http://com" => nil,
297
+ "http://alex.pages.examplecom" => nil,
298
+ "example" => nil,
299
+ "http://127.0.0.1" => nil,
300
+ "localhost" => nil
301
+ }
302
+
303
+ url_list.each_pair do |url, expected_result|
304
+ it "should extract #{expected_result.inspect} from #{url}" do
305
+ u = PostRank::URI.clean(url, :raw => true)
306
+ u.domain.should == expected_result
307
+ end
308
+ end
300
309
  end
301
310
  end
302
311
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: postrank-uri
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.9
5
+ version: 1.0.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ilya Grigorik
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-08 00:00:00 -04:00
13
+ date: 2011-05-05 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency