Skip to content

Commit ecb7662

Browse files
authored
Merge pull request #1856 from libris/fix/dont-guess-format-without-data-prefix
fix(rest): don't infer format on bare IDs
2 parents 612661f + e817341 commit ecb7662

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎rest/src/main/groovy/whelk/rest/api/CrudGetRequest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static CrudGetRequest parse(HttpServletRequest request) {
3232
private CrudGetRequest(HttpServletRequest request) {
3333
this.request = request;
3434
parsePath(getPath());
35-
contentType = getBestContentType(getAcceptHeader(request), dataLeaf != null ? dataLeaf : resourceId);
35+
contentType = getBestContentType(getAcceptHeader(request), dataLeaf != null ? dataLeaf : "");
3636
lens = parseLens(request);
3737
profile = parseProfile(request);
3838

‎rest/src/test/groovy/whelk/rest/api/CrudSpec.groovy‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,25 @@ class CrudSpec extends Specification {
187187
response.getContentType() == "application/ld+json"
188188
}
189189

190+
def "GET /<id> should display requested document if id contains a dot"() {
191+
given:
192+
def id = "https://id.kb.se/policy/kb/digisaml/1.0"
193+
request.getPathInfo() >> {
194+
'/' + id
195+
}
196+
request.getHeader("Accept") >> {
197+
"*/*"
198+
}
199+
storage.load(_, _) >> {
200+
new Document(["@graph": [["@id": id, "foo": "bar", 'mainEntity': ["@id": id + '#it']], ["@id": id + '#it']]])
201+
}
202+
when:
203+
crud.doGet(request, response)
204+
then:
205+
response.getStatus() == HttpServletResponse.SC_OK
206+
response.getContentType() == "application/ld+json"
207+
}
208+
190209
def "GET /<sameAs ID> should return 302 Found"() {
191210
given:
192211
def id = BASE_URI.resolve("/1234").toString()

0 commit comments

Comments
 (0)