tasks/jsonld/js/jsonld.js
function _expandIri(activeCtx, value, relativeTo, localCtx, defined) {
  // already expanded
  if(value === null || _isKeyword(value)) {
    return value;
  }

  // define term dependency if not defined
  if(localCtx && value in localCtx && defined[value] !== true) {
    _createTermDefinition(activeCtx, localCtx, value, defined);
  }

  relativeTo = relativeTo || {};
  if(relativeTo.vocab) {
    var mapping = activeCtx.mappings[value];

    // value is explicitly ignored with a null mapping
    if(mapping === null) {
      return null;
    }

    if(mapping) {
      // value is a term
      return mapping['@id'];
    }
  }

  // split value into prefix:suffix
  var colon = value.indexOf(':');
  if(colon !== -1) {
    var prefix = value.substr(0, colon);
    var suffix = value.substr(colon + 1);

    // do not expand blank nodes (prefix of '_') or already-absolute
    // IRIs (suffix of '//')
    if(prefix === '_' || suffix.indexOf('//') === 0) {
      return value;
    }

    // prefix dependency not defined, define it
    if(localCtx && prefix in localCtx) {
      _createTermDefinition(activeCtx, localCtx, prefix, defined);
    }

    // use mapping if prefix is defined
    var mapping = activeCtx.mappings[prefix];
    if(mapping) {
      return mapping['@id'] + suffix;
    }

    // already absolute IRI
    return value;
  }

  // prepend vocab
  if(relativeTo.vocab && '@vocab' in activeCtx) {
    return activeCtx['@vocab'] + value;
  }

  // prepend base
  var rval = value;
  if(relativeTo.base) {
    rval = _prependBase(activeCtx['@base'], rval);
  }

  if(localCtx) {
    // value must now be an absolute IRI
    if(!_isAbsoluteIri(rval)) {
      throw new JsonLdError(
        'Invalid JSON-LD syntax; a @context value does not expand to ' +
        'an absolute IRI.',
        'jsonld.SyntaxError', {context: localCtx, value: value});
    }
  }

  return rval;
}
function _expandIri(activeCtx, value, relativeTo, localCtx, defined) {
  // already expanded
  if(value === null || _isKeyword(value)) {
    return value;
  }

  // define term dependency if not defined
  if(localCtx && value in localCtx && defined[value] !== true) {
    _createTermDefinition(activeCtx, localCtx, value, defined);
  }

  relativeTo = relativeTo || {};
  if(relativeTo.vocab) {
    var mapping = activeCtx.mappings[value];

    // value is explicitly ignored with a null mapping
    if(mapping === null) {
      return null;
    }

    if(mapping) {
      // value is a term
      return mapping['@id'];
    }
  }

  // split value into prefix:suffix
  var colon = value.indexOf(':');
  if(colon !== -1) {
    var prefix = value.substr(0, colon);
    var suffix = value.substr(colon + 1);

    // do not expand blank nodes (prefix of '_') or already-absolute
    // IRIs (suffix of '//')
    if(prefix === '_' || suffix.indexOf('//') === 0) {
      return value;
    }

    // prefix dependency not defined, define it
    if(localCtx && prefix in localCtx) {
      _createTermDefinition(activeCtx, localCtx, prefix, defined);
    }

    // use mapping if prefix is defined
    var mapping = activeCtx.mappings[prefix];
    if(mapping) {
      return mapping['@id'] + suffix;
    }

    // already absolute IRI
    return value;
  }

  // prepend vocab
  if(relativeTo.vocab && '@vocab' in activeCtx) {
    return activeCtx['@vocab'] + value;
  }

  // prepend base
  var rval = value;
  if(relativeTo.base) {
    rval = _prependBase(activeCtx['@base'], rval);
  }

  if(localCtx) {
    // value must now be an absolute IRI
    if(!_isAbsoluteIri(rval)) {
      throw new JsonLdError(
        'Invalid JSON-LD syntax; a @context value does not expand to ' +
        'an absolute IRI.',
        'jsonld.SyntaxError', {context: localCtx, value: value});
    }
  }

  return rval;
}
function _expandIri ( activeCtx , value , relativeTo , localCtx , defined ) { // already expanded if ( value === null || _isKeyword ( value ) ) { return value ; } // define term dependency if not defined if ( localCtx && value in localCtx && defined [ value ] !== true ) { _createTermDefinition ( activeCtx , localCtx , value , defined ) ; } relativeTo = relativeTo || { } ; if ( relativeTo . vocab ) { var mapping = activeCtx . mappings [ value ] ; // value is explicitly ignored with a null mapping if ( mapping === null ) { return null ; } if ( mapping ) { // value is a term return mapping [ '@id' ] ; } } // split value into prefix:suffix var colon = value . indexOf ( ':' ) ; if ( colon !== - 1 ) { var prefix = value . substr ( 0 , colon ) ; var suffix = value . substr ( colon + 1 ) ; // do not expand blank nodes (prefix of '_') or already-absolute // IRIs (suffix of '//') if ( prefix === '_' || suffix . indexOf ( '//' ) === 0 ) { return value ; } // prefix dependency not defined, define it if ( localCtx && prefix in localCtx ) { _createTermDefinition ( activeCtx , localCtx , prefix , defined ) ; } // use mapping if prefix is defined var mapping = activeCtx . mappings [ prefix ] ; if ( mapping ) { return mapping [ '@id' ] + suffix ; } // already absolute IRI return value ; } // prepend vocab if ( relativeTo . vocab && '@vocab' in activeCtx ) { return activeCtx [ '@vocab' ] + value ; } // prepend base var rval = value ; if ( relativeTo . base ) { rval = _prependBase ( activeCtx [ '@base' ] , rval ) ; } if ( localCtx ) { // value must now be an absolute IRI if ( ! _isAbsoluteIri ( rval ) ) { throw new JsonLdError ( 'Invalid JSON-LD syntax; a @context value does not expand to ' + 'an absolute IRI.' , 'jsonld.SyntaxError' , { context : localCtx , value : value } ) ; } } return rval ; }
Expands a string to a full IRI. The string may be a term, a prefix, a
relative IRI, or an absolute IRI. The associated absolute IRI will be
returned.

@param activeCtx the current active context.
@param value the string to expand.
@param relativeTo options for how to resolve relative IRIs:
base: true to resolve against the base IRI, false not to.
vocab: true to concatenate after @vocab, false not to.
@param localCtx the local context being processed (only given if called
during context processing).
@param defined a map for tracking cycles in context definitions (only given
if called during context processing).

@return the expanded value.
Expands a string to a full IRI . The string may be a term a prefix a relative IRI or an absolute IRI . The associated absolute IRI will be returned .