src/index.js
function normalizePath(path = '') {

  // Remove the trailing slash if one has been given
  if(path.length > 1 && path.endsWith('/')) {
    path = path.slice(0, -1);
  }

  // Remove the first slash
  if(path.startsWith('/')) {
    path = path.slice(1);
  }

  // Remove the query if it exists
  if(path.includes('?')) {
    path = path.split('?')[0];
  }

  // Decode the url
  path = decodeURIComponent(path);

  return path;
}
function normalizePath(path = '') {

  // Remove the trailing slash if one has been given
  if(path.length > 1 && path.endsWith('/')) {
    path = path.slice(0, -1);
  }

  // Remove the first slash
  if(path.startsWith('/')) {
    path = path.slice(1);
  }

  // Remove the query if it exists
  if(path.includes('?')) {
    path = path.split('?')[0];
  }

  // Decode the url
  path = decodeURIComponent(path);

  return path;
}
function normalizePath ( path = '' ) { // Remove the trailing slash if one has been given if ( path . length > 1 && path . endsWith ( '/' ) ) { path = path . slice ( 0 , - 1 ) ; } // Remove the first slash if ( path . startsWith ( '/' ) ) { path = path . slice ( 1 ) ; } // Remove the query if it exists if ( path . includes ( '?' ) ) { path = path . split ( '?' ) [ 0 ] ; } // Decode the url path = decodeURIComponent ( path ) ; return path ; }
Function that normalizes a path string
Function that normalizes a path string