Code coverage report for src/util.js

Statements: 91.67% (22 / 24)      Branches: 93.33% (28 / 30)      Functions: 100% (3 / 3)      Lines: 91.67% (22 / 24)      Ignored: none     

All files » src/ » util.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471 27 19     27 1     27     1 20       20   20 5     20   20 7     20       20     1 15 7     8     1 1  
export function _normalizeAbsolutePath(path, hasPushState, absolute = false) {
  if (!hasPushState && path[0] !== '#') {
    path = '#' + path;
  }
 
  if (hasPushState && absolute) {
    path = path.substring(1, path.length);
  }
 
  return path;
}
 
export function _createRootedPath(fragment, baseUrl, hasPushState, absolute) {
  Iif (isAbsoluteUrl.test(fragment)) {
    return fragment;
  }
 
  let path = '';
 
  if (baseUrl.length && baseUrl[0] !== '/') {
    path += '/';
  }
 
  path += baseUrl;
 
  if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {
    path += '/';
  }
 
  Iif (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {
    path = path.substring(0, path.length - 1);
  }
 
  return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);
}
 
export function _resolveUrl(fragment, baseUrl, hasPushState) {
  if (isRootedPath.test(fragment)) {
    return _normalizeAbsolutePath(fragment, hasPushState);
  }
 
  return _createRootedPath(fragment, baseUrl, hasPushState);
}
 
const isRootedPath = /^#?\//;
const isAbsoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;