#1464 some optimizations
This commit is contained in:
parent
9df2d77527
commit
cda94538e6
@ -114,17 +114,13 @@ module RedmineDmsf
|
|||||||
|
|
||||||
# Run method through proxy class - ensuring always compatible child is generated
|
# Run method through proxy class - ensuring always compatible child is generated
|
||||||
def child(name)
|
def child(name)
|
||||||
new_path = @path
|
new_path = normalized_path
|
||||||
new_path = "#{new_path}/" unless new_path[-1, 1] == '/'
|
|
||||||
new_path = "/#{new_path}" unless new_path[0, 1] == '/'
|
|
||||||
ResourceProxy.new "#{new_path}#{name}", request, response, @options.merge(user: @user)
|
ResourceProxy.new "#{new_path}#{name}", request, response, @options.merge(user: @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def child_project(project)
|
def child_project(project)
|
||||||
project_display_name = ProjectResource.create_project_name(project)
|
project_display_name = ProjectResource.create_project_name(project)
|
||||||
new_path = @path
|
new_path = normalized_path
|
||||||
new_path = "#{new_path}/" unless new_path[-1, 1] == '/'
|
|
||||||
new_path = "/#{new_path}" unless new_path[0, 1] == '/'
|
|
||||||
new_path += project_display_name
|
new_path += project_display_name
|
||||||
ResourceProxy.new new_path, request, response, @options.merge(user: @user, project: true)
|
ResourceProxy.new new_path, request, response, @options.merge(user: @user, project: true)
|
||||||
end
|
end
|
||||||
@ -185,6 +181,13 @@ module RedmineDmsf
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
# Add slash at the beginning and the end if missing
|
||||||
|
def normalized_path
|
||||||
|
new_path = @path
|
||||||
|
new_path << '/' unless new_path.end_with?('/')
|
||||||
|
new_path.start_with?('/') ? new_path : new_path.insert(0, '/')
|
||||||
|
end
|
||||||
|
|
||||||
def uri_encode(uri)
|
def uri_encode(uri)
|
||||||
uri.gsub(/[()&\[\]]/, '(' => '%28', ')' => '%29', '&' => '%26', '[' => '%5B', ']' => '5D')
|
uri.gsub(/[()&\[\]]/, '(' => '%28', ')' => '%29', '&' => '%26', '[' => '%5B', ']' => '5D')
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user