all files / src/ sputils.conversion.js

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                    
(function () {
  /**
   * @summary
   * Extracts the user name from a claims-token string
   * @function sputils.conversion.getUserNameFromClaim
   * @param {string} claimsString - the claims string
   * @returns {string} username
   * @example
   * var claimsToken = 'i:0ǵ.t|ipdomain|jdoe';
   * var username = sputils.conversion.getUserNameFromClaim(claimsToken);
   * console.log(username); // => 'jdoe'
   */
  var getUserNameFromClaim = function (claimsString) {
    var splitUserName = claimsString.split('|');
    return splitUserName[splitUserName.length - 1];
  };
 
  /** @namespace */
  sputils.conversion = {
    getUserNameFromClaim: getUserNameFromClaim
  };
})();