diff --git a/core/package-lock.json b/core/package-lock.json index 9095a2a..5ee7168 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -1,6 +1,6 @@ { "name": "@solid-rest/core", - "version": "2.0.5", + "version": "2.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/core/package.json b/core/package.json index b2068a1..93ee173 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@solid-rest/core", - "version": "2.0.6", + "version": "2.0.7", "author": "Jeff Zucker", "license": "MIT", "description": "treat any storage as a mini Solid server", diff --git a/core/src/handleResponse.js b/core/src/handleResponse.js index c91227e..c88732d 100644 --- a/core/src/handleResponse.js +++ b/core/src/handleResponse.js @@ -50,25 +50,26 @@ export async function handleResponse(response, originalRequest) { const request = this.requestObj; const item = this.item; const pathname = this.item.pathname; - const fn = this.basename(pathname, item.pathHandler); // CONTENT-TYPE +// const fn = this.basename(pathname, item.pathHandler); + const fn = this.basename(pathname); - headers['content-type'] = this.item.contentType; // LINK + headers['content-type'] = this.item.contentType; // CONTENT-TYPE - headers.link = headers.link || createLinkHeader(this.item); // ALLOW + headers.link = headers.link || createLinkHeader(this.item,fn); // LINK - headers.allow = createAllowHeader(this.patch, this.item.mode); // WAC-ALLOW + headers.allow = createAllowHeader(this.patch, this.item.mode); // ALLOW - headers['wac-allow'] = createWacHeader(this.item.mode); // DATE + headers['wac-allow'] = createWacHeader(this.item.mode); // WAC-ALLOW - headers.date = headers.date || new Date(Date.now()).toISOString(); // X-POWERED-BY + headers.date = headers.date || new Date(Date.now()).toISOString(); // DATE - headers['x-powered-by'] = headers['x-powered-by'] || (await this.perform('STORAGE_NAME')); // LOCATION (we pre-populated this in performRequestedMethod.js) + headers['x-powered-by'] = headers['x-powered-by'] || (await this.perform('STORAGE_NAME')); // LOCATION (we pre-populated this in performRequestedMethod.js) // X-POWERED-BY - if (this.response && this.response.headers) headers.location = this.response.headers.location; // ACCEPT-PATCH & MS-AUTHOR-VIA + if (this.response && this.response.headers) headers.location = this.response.headers.location; - if (this.patch) { + if (this.patch) { // ACCEPT-PATCH & MS-AUTHOR-VIA headers['accept-patch'] = ['application/sparql-update']; - headers['ms-author-via'] = ["SPARQL"]; + headers['ms-author-via'] = ["SPARQL"]; } const body = finalResponse.body || this.response.body || ""; // Now we merge headers we created with response headers, prefering response @@ -79,6 +80,9 @@ export async function handleResponse(response, originalRequest) { headers.status = headers.status || this.response.headers.status || 500; headers.statusText = headers.statusText || statusText[headers.status]; // Now we create & return the Response object + for(var h of Object.keys(headers)){ + if(! headers[h]) delete headers[h]; + } if (originalRequest.plainResponse) { // from a server that wants to munge @@ -119,19 +123,21 @@ function createAllowHeader(patch, mode) { } function createLinkHeader(item) { + let fn = item.pathname.replace(/.*\//,''); let ext = item.extension; let isContainer = item.isContainer; - let link; if (ext === '.acl') // .acl not controlledBy or describedBy anything - return `; rel="type"`;else if (ext === '.meta') { - return; - `<${fn}.acl>; rel="acl",` // .meta controlledBy .meta.acl - + `; rel="type"`; - } else if (isContainer) { - return; - `<.meta>; rel="describedBy", <.acl>; rel="acl",` + `; rel="type",` + `; rel="type"` + `; rel="type"`; - } else { - return; - `<${fn}.meta>; rel="describedBy", <${fn}.acl>; rel="acl",` + `; rel="type"`; + return `; rel="type"`; + else if (ext === '.meta') { + return `<${fn}.acl>; rel="acl",` // .meta controlledBy .meta.acl + + `; rel="type"`; + } + else if (isContainer) { + return `<.meta>; rel="describedBy", <.acl>; rel="acl",` + `; rel="type",` + `; rel="type"` + `; rel="type"`; + } + else { + let link = `<${fn}.meta>; rel="describedBy", <${fn}.acl>; rel="acl",` + `; rel="type"`; + console.log(33,item,link); + return link; } } // THE END! diff --git a/file/package-lock.json b/file/package-lock.json index d00c136..6094da7 100644 --- a/file/package-lock.json +++ b/file/package-lock.json @@ -1,6 +1,6 @@ { "name": "@solid-rest/file", - "version": "2.0.6", + "version": "2.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -330,9 +330,9 @@ } }, "@solid-rest/core": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@solid-rest/core/-/core-2.0.5.tgz", - "integrity": "sha512-FA6cuqdgE4uxlSyRT5HU4LTnGFO+6o2mmwtHE/cQteCkqr+kusabMTgR0vNamSr/qgMQZqN4IbjTVNEmubrxUw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@solid-rest/core/-/core-2.0.6.tgz", + "integrity": "sha512-FfKEg5C1jn5blCpQ+2tsozJoyvjO8UuL3xfPnFGWuwdypQV9s0KNQrvzMZ+U5s+sEWnBSiy1JWBqXO2ivLD/Hw==", "requires": { "cross-fetch": "3.0.6", "mime-types": "2.1.27", diff --git a/file/package.json b/file/package.json index 5606580..db19ef5 100644 --- a/file/package.json +++ b/file/package.json @@ -1,6 +1,6 @@ { "name": "@solid-rest/file", - "version": "2.0.7", + "version": "2.0.8", "author": "Jeff Zucker", "license": "MIT", "description": "solid-rest plugin for filesystems", @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/solid/solid-rest#readme", "dependencies": { - "@solid-rest/core": "^2.0.6", + "@solid-rest/core": "^2.0.7", "concat-stream": "^2.0.0", "fs-extra": "^9.0.1", "mime-types": "^2.1.27", diff --git a/file/src/index.js b/file/src/index.js index 9d40136..ff2878b 100644 --- a/file/src/index.js +++ b/file/src/index.js @@ -1,6 +1,7 @@ import libPath from "path"; import { Readable } from "stream"; -import SolidRest from "@solid-rest/core"; +//import SolidRest from "@solid-rest/core"; +import SolidRest from "../../../core/"; import fs from "fs-extra"; import mime from "mime-types"; // import concatStream from "concat-stream";