Open jaxoncreed opened 3 years ago
At least as far as the typings are concerned, options.data
is string | undefined
, but jsonString
is string | undefined | null
. All this does is handle the case where jsonString
is null.
@bourgeoa. I looked into it a bit more. options.data
is allowed to be undefined as defined here https://github.com/linkeddata/rdflib.js/blob/main/src/fetcher.ts#L187. It's optional, so undefined
is allowed. Do you think it shouldn't be optional?
So it is a question of whether we should let the user create an invalid JSON-LD file. If we say || undefined, we are saying - go ahead create an empty JSON-LD file, you'lll be sorry later, but you asked for it. I we say || {} we are creating something that a later GET with accept=json-ld will not fail on.
I guess my tendency would be to go ahead and supply the {}.
The intent of the user's request is "create an empty JSON-LD resource". And BTW I mean jsonString || "{}"; - that will create an empty JSON-LD resource.
Other Test and Linter Fixes: