src/responder.js
function extractUsernameFromLink(steemitLink) {
  if (isValidSteemitLink(steemitLink)) {
    const usernamePos = steemitLink.search(/\/@.+\//);
    if (usernamePos === -1) return;

    const firstPart = steemitLink.slice(usernamePos + 2); // adding 2 to remove "/@"
    return firstPart.slice(0, firstPart.search('/'));
  }
}
function extractUsernameFromLink(steemitLink) {
  if (isValidSteemitLink(steemitLink)) {
    const usernamePos = steemitLink.search(/\/@.+\//);
    if (usernamePos === -1) return;

    const firstPart = steemitLink.slice(usernamePos + 2); // adding 2 to remove "/@"
    return firstPart.slice(0, firstPart.search('/'));
  }
}
function extractUsernameFromLink ( steemitLink ) { if ( isValidSteemitLink ( steemitLink ) ) { const usernamePos = steemitLink . search ( / \/@.+\/ / ) ; if ( usernamePos === - 1 ) return ; const firstPart = steemitLink . slice ( usernamePos + 2 ) ; // adding 2 to remove "/@" return firstPart . slice ( 0 , firstPart . search ( '/' ) ) ; } }
Should input a full steemit article link and return the username of the author
@param {string} steemitLink
Should input a full steemit article link and return the username of the author