Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0809c675
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0809c675
编写于
10月 31, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove the :path feature to redirects, since it cannot work
上级
a8a42648
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
48 deletion
+7
-48
actionpack/lib/action_dispatch/routing/redirection.rb
actionpack/lib/action_dispatch/routing/redirection.rb
+7
-15
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+0
-33
未找到文件。
actionpack/lib/action_dispatch/routing/redirection.rb
浏览文件 @
0809c675
...
@@ -68,23 +68,15 @@ def redirect(*args, &block)
...
@@ -68,23 +68,15 @@ def redirect(*args, &block)
def
options_proc
(
options
)
def
options_proc
(
options
)
proc
do
|
params
,
request
|
proc
do
|
params
,
request
|
path
=
if
options
[
:path
].
nil?
url_options
=
{
request
.
path
elsif
params
.
empty?
||
!
options
[
:path
].
match
(
/%\{\w*\}/
)
options
.
delete
(
:path
)
else
(
options
.
delete
(
:path
)
%
params
)
end
default_options
=
{
:protocol
=>
request
.
protocol
,
:protocol
=>
request
.
protocol
,
:host
=>
request
.
host
,
:host
=>
request
.
host
,
:port
=>
request
.
optional_port
,
:port
=>
request
.
optional_port
,
:path
=>
path
,
:path
=>
request
.
path
,
:params
=>
request
.
query_parameters
:params
=>
request
.
query_parameters
}
}
.
merge
options
ActionDispatch
::
Http
::
URL
.
url_for
(
options
.
reverse_merge
(
default_options
))
ActionDispatch
::
Http
::
URL
.
url_for
url_options
end
end
end
end
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
0809c675
...
@@ -62,13 +62,8 @@ def self.call(params, request)
...
@@ -62,13 +62,8 @@ def self.call(params, request)
match
'secure'
,
:to
=>
redirect
(
"/secure/login"
)
match
'secure'
,
:to
=>
redirect
(
"/secure/login"
)
match
'mobile'
,
:to
=>
redirect
(
:subdomain
=>
'mobile'
)
match
'mobile'
,
:to
=>
redirect
(
:subdomain
=>
'mobile'
)
match
'documentation'
,
:to
=>
redirect
(
:domain
=>
'example-documentation.com'
,
:path
=>
''
)
match
'new_documentation'
,
:to
=>
redirect
(
:path
=>
'/documentation/new'
)
match
'super_new_documentation'
,
:to
=>
redirect
(
:host
=>
'super-docs.com'
)
match
'super_new_documentation'
,
:to
=>
redirect
(
:host
=>
'super-docs.com'
)
match
'stores/:name'
,
:to
=>
redirect
(
:subdomain
=>
'stores'
,
:path
=>
'/%{name}'
)
match
'stores/:name(*rest)'
,
:to
=>
redirect
(
:subdomain
=>
'stores'
,
:path
=>
'/%{name}%{rest}'
)
match
'youtube_favorites/:youtube_id/:name'
,
:to
=>
redirect
(
YoutubeFavoritesRedirector
)
match
'youtube_favorites/:youtube_id/:name'
,
:to
=>
redirect
(
YoutubeFavoritesRedirector
)
constraints
(
lambda
{
|
req
|
true
})
do
constraints
(
lambda
{
|
req
|
true
})
do
...
@@ -711,20 +706,6 @@ def test_redirect_hash_with_subdomain
...
@@ -711,20 +706,6 @@ def test_redirect_hash_with_subdomain
end
end
end
end
def
test_redirect_hash_with_domain_and_path
with_test_routes
do
get
'/documentation'
verify_redirect
'http://www.example-documentation.com'
end
end
def
test_redirect_hash_with_path
with_test_routes
do
get
'/new_documentation'
verify_redirect
'http://www.example.com/documentation/new'
end
end
def
test_redirect_hash_with_host
def
test_redirect_hash_with_host
with_test_routes
do
with_test_routes
do
get
'/super_new_documentation?section=top'
get
'/super_new_documentation?section=top'
...
@@ -732,20 +713,6 @@ def test_redirect_hash_with_host
...
@@ -732,20 +713,6 @@ def test_redirect_hash_with_host
end
end
end
end
def
test_redirect_hash_path_substitution
with_test_routes
do
get
'/stores/iernest'
verify_redirect
'http://stores.example.com/iernest'
end
end
def
test_redirect_hash_path_substitution_with_catch_all
with_test_routes
do
get
'/stores/iernest/products'
verify_redirect
'http://stores.example.com/iernest/products'
end
end
def
test_redirect_class
def
test_redirect_class
with_test_routes
do
with_test_routes
do
get
'/youtube_favorites/oHg5SJYRHA0/rick-rolld'
get
'/youtube_favorites/oHg5SJYRHA0/rick-rolld'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录