Skip to content

Commit bb68760

Browse files
Add an illustrative LdpGetOperation.from()
1 parent 4bd804b commit bb68760

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

lib/api/ldp/ldp-operation.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const url = require('url')
4+
const glob = require('glob')
45
const HttpError = require('standard-http-error')
56

67
const OPERATIONS = {
@@ -92,7 +93,26 @@ class LdpHeadOperation extends LdpOperation {
9293
* - "Glob pattern request" if glob magic chars are detected (ie `*`)
9394
* - Otherwise, plain Get request
9495
*/
95-
class LdpGetOperation extends LdpOperation {}
96+
class LdpGetOperation extends LdpOperation {
97+
static from ({headers, target, bodyStream, authentication, store}) {
98+
const targetUrl = url.format(target)
99+
100+
if (glob.hasMagic(targetUrl)) {
101+
// this is a Ldp Glob operation, return that
102+
}
103+
104+
// check to see if target is a container (based on Link: type rel)
105+
// ...
106+
// if it is a container, check to see if index.html exists
107+
const indexFile = url.resolve(targetUrl, '/index.html')
108+
if (store.exists(indexFile)) {
109+
// this is an implicit Get operation to the index file
110+
// return it
111+
}
112+
113+
// return plain get operation
114+
}
115+
}
96116

97117
/**
98118
* Creates a resource or container, and any necessary containers above it in

0 commit comments

Comments
 (0)