src/index.js
function buildUrl(value, options, file) {
  const [gist] = value.split(/[?#]/);

  const [inlineUsername, id] =
    gist.indexOf("/") > 0 ? gist.split("/") : [null, gist];

  // username can come from inline code or options
  const username = inlineUsername || options.username;

  // checks for a valid username
  if (username == null || username.trim().length === 0) {
    throw new Error("Missing username information");
  }

  // checks for a valid id
  if (id == null || id.trim().length === 0) {
    throw new Error("Missing gist id information");
  }

  // builds the url and completes it with the file if any
  let url = `${baseUrl}/${username}/${id}.json`;
  if (file != null) {
    url += `?file=${file}`;
  }

  return url;
}
function buildUrl(value, options, file) {
  const [gist] = value.split(/[?#]/);

  const [inlineUsername, id] =
    gist.indexOf("/") > 0 ? gist.split("/") : [null, gist];

  // username can come from inline code or options
  const username = inlineUsername || options.username;

  // checks for a valid username
  if (username == null || username.trim().length === 0) {
    throw new Error("Missing username information");
  }

  // checks for a valid id
  if (id == null || id.trim().length === 0) {
    throw new Error("Missing gist id information");
  }

  // builds the url and completes it with the file if any
  let url = `${baseUrl}/${username}/${id}.json`;
  if (file != null) {
    url += `?file=${file}`;
  }

  return url;
}
function buildUrl ( value , options , file ) { const [ gist ] = value . split ( / [?#] / ) ; const [ inlineUsername , id ] = gist . indexOf ( "/" ) > 0 ? gist . split ( "/" ) : [ null , gist ] ; // username can come from inline code or options const username = inlineUsername || options . username ; // checks for a valid username if ( username == null || username . trim ( ) . length === 0 ) { throw new Error ( "Missing username information" ) ; } // checks for a valid id if ( id == null || id . trim ( ) . length === 0 ) { throw new Error ( "Missing gist id information" ) ; } // builds the url and completes it with the file if any let url = ` ${ baseUrl } ${ username } ${ id } ` ; if ( file != null ) { url += ` ${ file } ` ; } return url ; }
Builds the gist url.
@param {string} value the value of the inlineCode block.
@param {PluginOptions} options the options of the plugin.
@param {string} file the file to be loaded.
@returns {string} the gist url.
Builds the gist url .