rack_slashless 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +30 -0
- data/README.md +37 -2
- data/Rakefile +5 -0
- data/lib/rack_slashless.rb +6 -7
- data/rack_slashless.gemspec +3 -3
- metadata +9 -5
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rack_slashless (0.0.6)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rack (1.4.1)
|
11
|
+
rack-test (0.6.2)
|
12
|
+
rack (>= 1.0)
|
13
|
+
rake (10.0.3)
|
14
|
+
rspec (2.12.0)
|
15
|
+
rspec-core (~> 2.12.0)
|
16
|
+
rspec-expectations (~> 2.12.0)
|
17
|
+
rspec-mocks (~> 2.12.0)
|
18
|
+
rspec-core (2.12.2)
|
19
|
+
rspec-expectations (2.12.0)
|
20
|
+
diff-lcs (~> 1.1.3)
|
21
|
+
rspec-mocks (2.12.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
rack-test
|
28
|
+
rack_slashless!
|
29
|
+
rake
|
30
|
+
rspec (~> 2)
|
data/README.md
CHANGED
@@ -1,2 +1,37 @@
|
|
1
|
-
|
2
|
-
==============
|
1
|
+
Rack::Slashless
|
2
|
+
==============
|
3
|
+
Rack::Slashless is Rack application that redirects every GET requests ending by a `/` to the same url without the `/`.
|
4
|
+
|
5
|
+
Rack::Slashless is an easy SEO win, the gem will avoid duplicate contents across your site. For example, you can access the page `example.com/blog/` or `example.com/blog`, both have exactly the same content but with a different url, this causes a duplicate content for Google.
|
6
|
+
|
7
|
+
If you want more details regarding Duplicate Content, here is the [Guide](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66359) from Google.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
Install the gem locally using:
|
11
|
+
``` ruby
|
12
|
+
gem install rack_slashless
|
13
|
+
```
|
14
|
+
|
15
|
+
... or add it to your project's Gemfile:
|
16
|
+
``` ruby
|
17
|
+
gem 'rack_slashless'
|
18
|
+
```
|
19
|
+
|
20
|
+
## Rails
|
21
|
+
**config/application.rb**
|
22
|
+
``` ruby
|
23
|
+
config.middleware.insert_before(0, "Rack::Slashless")
|
24
|
+
```
|
25
|
+
|
26
|
+
## Sinatra
|
27
|
+
**app.rb** (your application file)
|
28
|
+
``` ruby
|
29
|
+
require 'sinatra'
|
30
|
+
require 'rack_slashless'
|
31
|
+
|
32
|
+
use Rack::Slashless
|
33
|
+
```
|
34
|
+
|
35
|
+
## Author
|
36
|
+
Gregory Marcilhacy
|
37
|
+
License: MIT
|
data/Rakefile
ADDED
data/lib/rack_slashless.rb
CHANGED
@@ -9,13 +9,12 @@ module Rack
|
|
9
9
|
request = Rack::Request.new(env)
|
10
10
|
if request.get? && request.path_info.match(/\w+\/$/)
|
11
11
|
destination = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
[301, {'Location' => destination}, ['Redirecting to the same url but with the ending /']]
|
12
|
+
"#{request.scheme}://",
|
13
|
+
request.env['SERVER_NAME'],
|
14
|
+
request.path_info[0..-2],
|
15
|
+
(request.query_string.empty? ? '' : "?#{request.query_string}")
|
16
|
+
].join
|
17
|
+
[301, {'Location' => destination}, ["Redirecting to #{destination}"]]
|
19
18
|
else
|
20
19
|
@app.call(env)
|
21
20
|
end
|
data/rack_slashless.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
9
9
|
gem.name = "rack_slashless"
|
10
10
|
gem.require_paths = ["lib"]
|
11
|
-
gem.version = "0.0.
|
11
|
+
gem.version = "0.0.6"
|
12
12
|
gem.license = "MIT"
|
13
13
|
|
14
|
-
gem.add_development_dependency 'rspec'
|
15
|
-
gem.add_development_dependency '
|
14
|
+
gem.add_development_dependency 'rspec', '>= 2'
|
15
|
+
gem.add_development_dependency 'rack-test'
|
16
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_slashless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,9 +26,9 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: rack-test
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -51,7 +51,11 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- .travis.yml
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
54
57
|
- README.md
|
58
|
+
- Rakefile
|
55
59
|
- lib/rack_slashless.rb
|
56
60
|
- rack_slashless.gemspec
|
57
61
|
- spec/rack_slashless_spec.rb
|