Skip to content

Commit

Permalink
Fixes issue with URL encoding of links. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jejacks0n committed Apr 13, 2019
1 parent 729b11e commit f690932
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/apitome/docs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def simulate
def file_for(file, readme: false)
if Apitome.configuration.remote_url
file = readme ? file : "#{Apitome.configuration.doc_path}/#{file}"
file = URI.encode("#{Apitome.configuration.remote_url}/#{file}")
file = CGI.escape("#{Apitome.configuration.remote_url}/#{file}")
else
file = Apitome.configuration.root.join(Apitome.configuration.doc_path, file)
raise Apitome::FileNotFoundError.new("Unable to find #{file}") unless File.exist?(file)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/apitome/docs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ def format_scope(scopes)
end

def resource_link(resource)
"#{Apitome.configuration.mount_at}/#{resource['examples'].first['link'].gsub(/\.json$/, '')}"
"#{Apitome.configuration.mount_at}/#{CGI.escape(resource['examples'].first['link'].gsub(/\.json$/, ''))}"
end

def example_link(example)
"#{Apitome.configuration.mount_at}/#{example['link'].gsub(/\.json$/, '')}"
"#{Apitome.configuration.mount_at}/#{CGI.escape(example['link'].gsub(/\.json$/, ''))}"
end

def link_active?(link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"resource": "Access Tokens",
"http_method": "POST",
"route": "/api/oauth/token",
"description": "User access token (password)",
"description": "User access token [password]",
"explanation": "Most API endpoints require a user access token (e.g. for a user to be authenticated). This is similar to the\n[client access token](#access-tokens-client-access-token-client-credentials-), but requires the user credentials\nto be provided for one to be granted.\n\nIf an invalid/expired token is provided to any API endpoint, a 401 status code is returned, at which time a new\ntoken should be requested [using the refresh token](#access-tokens-user-access-token-refresh-token-) as returned\nhere.\n\nStoring the refresh token on the client is recommended for retrieving a new access token, and user credentials\nshould not be stored on the client. If authenticating via the refresh token fails, the user should be signed out\nand displayed a sign in view -- their user account may have been locked out, or your client credentials revoked.",
"parameters": [
{
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/doc/api/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"groups": "all"
},
{
"description": "User access token (password)",
"link": "access_tokens/user_access_token_(password).json",
"description": "User access token [password]",
"link": "access_tokens/user_access_token_[password].json",
"groups": "all"
},
{
Expand Down

0 comments on commit f690932

Please sign in to comment.