isomorphic-git 1.26.1 → 1.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import AsyncLock from 'async-lock';
2
2
  import Hash from 'sha.js/sha1.js';
3
- import { join } from 'path';
4
3
  import crc32 from 'crc-32';
5
4
  import pako from 'pako';
6
5
  import pify from 'pify';
@@ -1476,6 +1475,40 @@ function compareRefNames(a, b) {
1476
1475
  return tmp
1477
1476
  }
1478
1477
 
1478
+ const memo = new Map();
1479
+ function normalizePath(path) {
1480
+ let normalizedPath = memo.get(path);
1481
+ if (!normalizedPath) {
1482
+ normalizedPath = normalizePathInternal(path);
1483
+ memo.set(path, normalizedPath);
1484
+ }
1485
+ return normalizedPath
1486
+ }
1487
+
1488
+ function normalizePathInternal(path) {
1489
+ path = path
1490
+ .split('/./')
1491
+ .join('/') // Replace '/./' with '/'
1492
+ .replace(/\/{2,}/g, '/'); // Replace consecutive '/'
1493
+
1494
+ if (path === '/.') return '/' // if path === '/.' return '/'
1495
+ if (path === './') return '.' // if path === './' return '.'
1496
+
1497
+ if (path.startsWith('./')) path = path.slice(2); // Remove leading './'
1498
+ if (path.endsWith('/.')) path = path.slice(0, -2); // Remove trailing '/.'
1499
+ if (path.length > 1 && path.endsWith('/')) path = path.slice(0, -1); // Remove trailing '/'
1500
+
1501
+ if (path === '') return '.' // if path === '' return '.'
1502
+
1503
+ return path
1504
+ }
1505
+
1506
+ // For some reason path.posix.join is undefined in webpack
1507
+
1508
+ function join(...parts) {
1509
+ return normalizePath(parts.map(normalizePath).join('/'))
1510
+ }
1511
+
1479
1512
  // This is straight from parse_unit_factor in config.c of canonical git
1480
1513
  const num = val => {
1481
1514
  val = val.toLowerCase();
@@ -1590,7 +1623,7 @@ const getPath = (section, subsection, name) => {
1590
1623
  .join('.')
1591
1624
  };
1592
1625
 
1593
- const normalizePath = path => {
1626
+ const normalizePath$1 = path => {
1594
1627
  const pathSegments = path.split('.');
1595
1628
  const section = pathSegments.shift();
1596
1629
  const name = pathSegments.pop();
@@ -1646,7 +1679,7 @@ class GitConfig {
1646
1679
  }
1647
1680
 
1648
1681
  async get(path, getall = false) {
1649
- const normalizedPath = normalizePath(path).path;
1682
+ const normalizedPath = normalizePath$1(path).path;
1650
1683
  const allValues = this.parsedConfig
1651
1684
  .filter(config => config.path === normalizedPath)
1652
1685
  .map(({ section, name, value }) => {
@@ -1684,7 +1717,7 @@ class GitConfig {
1684
1717
  name,
1685
1718
  path: normalizedPath,
1686
1719
  sectionPath,
1687
- } = normalizePath(path);
1720
+ } = normalizePath$1(path);
1688
1721
  const configIndex = findLastIndex(
1689
1722
  this.parsedConfig,
1690
1723
  config => config.path === normalizedPath
@@ -7412,8 +7445,8 @@ function filterCapabilities(server, client) {
7412
7445
 
7413
7446
  const pkg = {
7414
7447
  name: 'isomorphic-git',
7415
- version: '1.26.1',
7416
- agent: 'git/isomorphic-git@1.26.1',
7448
+ version: '1.26.3',
7449
+ agent: 'git/isomorphic-git@1.26.3',
7417
7450
  };
7418
7451
 
7419
7452
  class FIFO {