Skip to content

Commit 47091e4

Browse files
committed
Also add extension on POSTed Turtle files.
1 parent 8d4a7a1 commit 47091e4

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

lib/ldp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ var ldpContainer = require('./ldp-container')
1717
var parse = require('./utils').parse
1818

1919
const DEFAULT_CONTENT_TYPE = 'text/turtle'
20-
const DEFAULT_EXTENSION = '.ttl'
2120

2221
const RDF_MIME_TYPES = [
2322
'text/turtle', // .ttl
@@ -196,8 +195,10 @@ class LDP {
196195
return
197196
}
198197
}
199-
// No need to use the default extension, as we know its MIME type already
200-
if (extension === DEFAULT_EXTENSION) extension = ''
198+
// Containers should not receive an extension
199+
if (container) {
200+
extension = ''
201+
}
201202
// TODO: possibly package this in ldp.post
202203
ldp.getAvailablePath(host, containerPath, { slug, extension }).then(resourcePath => {
203204
debug.handlers('POST -- Will create at: ' + resourcePath)

test/integration/http-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ describe('HTTP APIs', function () {
510510
server.post('/post-tests/')
511511
.send(postRequest1Body)
512512
.set('content-type', 'text/turtle')
513-
.set('slug', 'post-resource-1.ttl')
513+
.set('slug', 'post-resource-1')
514514
.expect('location', /\/post-resource-1/)
515515
.expect(hasHeader('describedBy', suffixMeta))
516516
.expect(hasHeader('acl', suffixAcl))
@@ -521,7 +521,7 @@ describe('HTTP APIs', function () {
521521
server.post('')
522522
.send(postRequest1Body)
523523
.set('content-type', 'text/turtle')
524-
.set('slug', 'post-test-target.ttl')
524+
.set('slug', 'post-test-target')
525525
.expect('location', /\/post-test-target\.ttl/)
526526
.expect(hasHeader('describedBy', suffixMeta))
527527
.expect(hasHeader('acl', suffixAcl))
@@ -531,15 +531,15 @@ describe('HTTP APIs', function () {
531531
server.post('/hello.html/')
532532
.send(postRequest1Body)
533533
.set('content-type', 'text/turtle')
534-
.set('slug', 'post-test-target2.ttl')
534+
.set('slug', 'post-test-target2')
535535
.expect(404, done)
536536
})
537537
it('should create a new slug if there is a resource with the same name',
538538
function (done) {
539539
server.post('/post-tests/')
540540
.send(postRequest1Body)
541541
.set('content-type', 'text/turtle')
542-
.set('slug', 'post-resource-1.ttl')
542+
.set('slug', 'post-resource-1')
543543
.expect(201, done)
544544
})
545545
it('should be able to delete newly created resource', function (done) {
@@ -624,9 +624,9 @@ describe('HTTP APIs', function () {
624624
.then(res => { response = res })
625625
)
626626

627-
it('is assigned an extensionless URL', () => {
627+
it('is assigned an URL with the .ttl extension', () => {
628628
expect(response.headers).to.have.property('location')
629-
expect(response.headers.location).to.match(/^\/post-tests\/[^./]+$/)
629+
expect(response.headers.location).to.match(/^\/post-tests\/[^./]+\.ttl$/)
630630
})
631631
})
632632

@@ -639,8 +639,8 @@ describe('HTTP APIs', function () {
639639
.then(res => { response = res })
640640
)
641641

642-
it('is assigned an extensionless URL', () => {
643-
expect(response.headers).to.have.property('location', '/post-tests/slug1')
642+
it('is assigned an URL with the .ttl extension', () => {
643+
expect(response.headers).to.have.property('location', '/post-tests/slug1.ttl')
644644
})
645645
})
646646

0 commit comments

Comments
 (0)