Skip to content

Commit e2aa46e

Browse files
authored
Merge pull request #645 from linkeddata/rmMetadata
remove metadata
2 parents cd9a596 + c45ae25 commit e2aa46e

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.14.0
1+
v18.19.0

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rdflib",
33
"description": "an RDF library for node.js. Suitable for client and server side.",
4-
"version": "2.2.34-beta",
4+
"version": "2.2.34-beta3",
55
"private": false,
66
"browserslist": [
77
"> 0.5%"

src/fetcher.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ export default class Fetcher implements CallbackifyInterface {
980980
const requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(st => st.subject)
981981
for (const request of requests) {
982982
const response = kb.any(request, this.ns.link('response'), null, meta) as Quad_Subject
983-
if (response !== undefined) { // ts
983+
if (response != undefined) { // ts
984984
const quad = kb.statementsMatching(response, this.ns.link('outOfDate'), true as any, meta)
985985
kb.remove(quad)
986986
options.force = true

src/store.ts

+25-10
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
871871
}
872872

873873
/**
874-
* Removes all statements in a doc, along with the related metadata including request/response
874+
* Removes all statements in a doc, along with the related metadata including request/response/status
875875
* @param doc - The document / graph
876876
*/
877877
removeDocument(doc: Quad_Graph): IndexedFormula {
@@ -881,27 +881,42 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
881881
for (var i = 0; i < sts.length; i++) {
882882
this.removeStatement(sts[i])
883883
}
884+
this.removeMatches(doc as Quad_Subject, null, null)
884885
return this
885886
}
886887

887888
removeMetadata(doc: Quad_Graph): IndexedFormula {
888889
const meta = this.sym('chrome://TheCurrentSession') // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
889-
const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#' // alain
890-
// remove request/response and metadata
890+
const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#'
891+
// remove status/response/request metadata
891892
const requests = this.statementsMatching(undefined, this.sym(`${linkNamespaceURI}requestedURI`), this.rdfFactory.literal(doc.value), meta).map(st => st.subject)
892893
for (var r = 0; r < requests.length; r++) {
893894
const request = requests[r]
894895
if (request != undefined) {
896+
// removeMatches unresolved issue with collection https://github.com/linkeddata/rdflib.js/issues/631
897+
let sts: Quad[]
898+
// status collection
899+
const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta) as Quad_Subject
900+
if (status != undefined) {
901+
sts = this.statementsMatching(status, this.sym(`${linkNamespaceURI}status`), null, meta).slice()
902+
for (var i = 0; i < sts.length; i++) {
903+
this.removeStatement(sts[i])
904+
}
905+
}
906+
// response items list
895907
const response = this.any(request, this.sym(`${linkNamespaceURI}response`), null, meta) as Quad_Subject
896-
if (response != undefined) { // ts
897-
this.removeMatches(response, null, null, meta)
908+
if (response != undefined) {
909+
sts = this.statementsMatching(response, null, null, meta).slice()
910+
for (var i = 0; i < sts.length; i++) {
911+
this.removeStatement(sts[i])
912+
}
898913
}
899-
// may be not needed
900-
const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta) as Quad_Subject
901-
if (status != undefined) { // ts
902-
this.removeMatches(status, null, null, meta)
914+
// request triples
915+
sts = this.statementsMatching(request, null, null, meta).slice()
916+
for (var i = 0; i < sts.length; i++) {
917+
this.removeStatement(sts[i])
903918
}
904-
this.removeMatches(request, null, null, meta)
919+
905920
}
906921
}
907922
this.removeMatches(this.sym(doc.value), null, null, meta) // content-type

0 commit comments

Comments
 (0)