Skip to content

Commit d51b9cb

Browse files
gkelloggdavidlehn
authored andcommitted
Add compactToRelative option.
1 parent 7359502 commit d51b9cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/jsonld.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ const wrapper = function(jsonld) {
9696
* [base] the base IRI to use.
9797
* [compactArrays] true to compact arrays to single values when
9898
* appropriate, false not to (default: true).
99+
* [compactToRelative] true to compact IRIs to be relative to document base,
100+
* false to keep absolute (default: true)
99101
* [graph] true to always output a top-level graph (default: false).
100102
* [expandContext] a context to expand with.
101103
* [skipExpansion] true to assume the input is expanded and skip
@@ -134,6 +136,7 @@ jsonld.compact = util.callbackify(async function(input, ctx, options) {
134136
options = _setDefaults(options, {
135137
base: _isString(input) ? input : '',
136138
compactArrays: true,
139+
compactToRelative: true,
137140
graph: false,
138141
skipExpansion: false,
139142
link: false,
@@ -144,6 +147,9 @@ jsonld.compact = util.callbackify(async function(input, ctx, options) {
144147
// API, it should only be called from framing
145148
options.skipExpansion = true;
146149
}
150+
if(!options.compactToRelative) {
151+
delete options.base;
152+
}
147153

148154
// expand input
149155
let expanded;

0 commit comments

Comments
 (0)