Permalink
Browse files

Merge pull request #122 from gvaughn/leading_slash_fix

remove leading slashes in paths for enterprise use
  • Loading branch information...
2 parents a91f087 + 23108b3 commit cd7a39bcf957ad0bfdb367f4523d6ac7f90a23e7 @catsby catsby committed Aug 7, 2012
Showing with 7 additions and 6 deletions.
  1. +3 −3 lib/octokit/client/contents.rb
  2. +1 −1 lib/octokit/client/markdown.rb
  3. +3 −2 lib/octokit/request.rb
@@ -12,7 +12,7 @@ module Contents
# @example Get the readme file for a repo
# Octokit.readme("pengwynn/octokit")
def readme(repo, options={})
- get("/repos/#{Repository.new repo}/readme", options, 3)
+ get("repos/#{Repository.new repo}/readme", options, 3)
end
# Receive a listing of a repository folder or the contents of a file
@@ -26,7 +26,7 @@ def readme(repo, options={})
# Octokit.contents("pengwynn/octokit", :path => 'lib/octokit.rb')
def contents(repo, options={})
repo_path = options.delete :path
- url = "/repos/#{Repository.new repo}/contents/#{repo_path}"
+ url = "repos/#{Repository.new repo}/contents/#{repo_path}"
get(url, options, 3)
end
@@ -42,7 +42,7 @@ def contents(repo, options={})
def archive_link(repo, options={})
repo_ref = options.delete :ref
format = (options.delete :format) || 'tarball'
- url = "/repos/#{Repository.new repo}/#{format}/#{repo_ref}"
+ url = "repos/#{Repository.new repo}/#{format}/#{repo_ref}"
headers = get(url, options, 3, false, true).headers
return headers['location']
end
@@ -14,7 +14,7 @@ module Markdown
def markdown(text, options={})
options[:text] = text
options[:repo] = Repository.new(options[:repo]) if options[:repo]
- post("/markdown", options, 3, true, true).body
+ post("markdown", options, 3, true, true).body
end
end
View
@@ -23,20 +23,21 @@ def put(path, options={}, version=api_version, authenticate=true, raw=false, for
end
def ratelimit
- headers = get("/rate_limit",{}, api_version, true, true).headers
+ headers = get("rate_limit",{}, api_version, true, true).headers
return headers["X-RateLimit-Limit"].to_i
end
alias rate_limit ratelimit
def ratelimit_remaining
- headers = get("/rate_limit",{}, api_version, true, true).headers
+ headers = get("rate_limit",{}, api_version, true, true).headers
return headers["X-RateLimit-Remaining"].to_i
end
alias rate_limit_remaining ratelimit_remaining
private
def request(method, path, options, version, authenticate, raw, force_urlencoded)
+ path.sub(%r{^/}, '') #leading slash in path fails in github:enterprise
response = connection(authenticate, raw, version, force_urlencoded).send(method) do |request|
case method
when :delete, :get

0 comments on commit cd7a39b

Please sign in to comment.