Skip to content

Commit

Permalink
use fetch when possible to avoid browser decoding of %2E
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Nov 20, 2018
1 parent 56de195 commit 329036b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
### 1.2.0 (2018-11-20)

* update QA which includes extended QA API and terms returned as json-ld
* update QA which includes...
* extended QA API (e.g. list, reload, fetch)
* fetch/show terms optionally returned as json-ld (default = json for backward compatibility)
* update dependencies for security vulnerabilities
* fix accuracy tests
* default term tests to use fetch instead of show when term identifier is a URI
* get list of authority names from QA AuthorityService

### 1.1.0 (2018-10-31)

Expand Down
21 changes: 18 additions & 3 deletions app/models/qa_server/term_scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@ def initialize(authority:, authority_name:, authority_scenario_config:, scenario
# Generate an example URL that can be called in a browser or through curl
# @return [String] the example URL
def url
subauth = "/#{subauthority_name}" if subauthority_name.present?
prefix = "#{QaServer::Engine.qa_engine_mount}/show/linked_data/#{authority_name.downcase}#{subauth}"
"#{prefix}/#{url_identifier}"
authority.auth_config.term.term_id_expects_uri? ? fetch_url : show_url
end

private

# Generate an example URL that can be called in a browser or through curl
# @return [String] the example URL
def show_url
"#{prefix_for_url('show')}/#{url_identifier}"
end

# Generate an example URL that can be called in a browser or through curl
# @return [String] the example URL
def fetch_url
"#{prefix_for_url('fetch')}?uri=#{url_identifier}"
end

def prefix_for_url(action)
subauth = "/#{subauthority_name}" if subauthority_name.present?
prefix = "#{QaServer::Engine.qa_engine_mount}/#{action}/linked_data/#{authority_name.downcase}#{subauth}"
end

# Convert identifier into URL safe version with encoding if needed.
def url_identifier
return uri_encode(identifier) if encode?
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/qa_server/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_required_generators

def add_to_gemfile
say_status('info', ' -- adding qa_server required gems', :blue)
gem 'qa', github: 'samvera/questioning_authority', branch: 'min_context'
gem 'qa', github: 'samvera/questioning_authority', tag: '496aaa34c4aba6d97d11737b229ea66ea4c64639'
gem 'linkeddata'

Bundler.with_clean_env do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"qa_replacement_patterns": {
"term_id": "term_uri"
},
"term_id": "ID",
"term_id": "URI",
"results": {
"id_predicate": "http://www.w3.org/2004/02/skos/core#notation",
"label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
Expand Down

0 comments on commit 329036b

Please sign in to comment.