Skip to content

Commit

Permalink
#1464 some optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed May 20, 2024
1 parent 9df2d77 commit cda9453
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/redmine_dmsf/webdav/base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,13 @@ def html_display

# Run method through proxy class - ensuring always compatible child is generated
def child(name)
new_path = @path
new_path = "#{new_path}/" unless new_path[-1, 1] == '/'
new_path = "/#{new_path}" unless new_path[0, 1] == '/'
new_path = normalized_path
ResourceProxy.new "#{new_path}#{name}", request, response, @options.merge(user: @user)
end

def child_project(project)
project_display_name = ProjectResource.create_project_name(project)
new_path = @path
new_path = "#{new_path}/" unless new_path[-1, 1] == '/'
new_path = "/#{new_path}" unless new_path[0, 1] == '/'
new_path = normalized_path
new_path += project_display_name
ResourceProxy.new new_path, request, response, @options.merge(user: @user, project: true)
end
Expand Down Expand Up @@ -185,6 +181,13 @@ def get_project(scope, name, parent_project)

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)
uri.gsub(/[()&\[\]]/, '(' => '%28', ')' => '%29', '&' => '%26', '[' => '%5B', ']' => '5D')
end
Expand Down

0 comments on commit cda9453

Please sign in to comment.