@duplojs/utils 1.4.41 → 1.4.42

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.
@@ -2,19 +2,13 @@
2
2
 
3
3
  var minElements = require('../../array/minElements.cjs');
4
4
 
5
- const extensionNameRegex = /.(\.[^./]+|\.)$/;
5
+ const extensionNameRegex = /\.([^./]+)$/;
6
6
  /**
7
7
  * {@include common/path/getExtensionName/index.md}
8
8
  */
9
9
  function getExtensionName(path) {
10
- if (path === "..") {
11
- return null;
12
- }
13
10
  const match = extensionNameRegex.exec(path);
14
11
  if (!!match && minElements.minElements(match, 2)) {
15
- if (match[1] === ".") {
16
- return null;
17
- }
18
12
  return match[1];
19
13
  }
20
14
  return null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Returns the last extension of a path, including the leading dot.
2
+ * Returns the last extension of a path, without the leading dot.
3
3
  *
4
4
  * **Supported call styles:**
5
5
  * - Classic: `getExtensionName(path)` -> returns the extension or null
@@ -8,9 +8,9 @@
8
8
  *
9
9
  * ```ts
10
10
  * const txtResult = Path.getExtensionName("/foo/bar.txt");
11
- * // txtResult: ".txt"
11
+ * // txtResult: "txt"
12
12
  * const tarResult = Path.getExtensionName("archive.tar.gz");
13
- * // tarResult: ".gz"
13
+ * // tarResult: "gz"
14
14
  * const dotResult = Path.getExtensionName("file.");
15
15
  * // dotResult: null
16
16
  * ```
@@ -1,18 +1,12 @@
1
1
  import { minElements } from '../../array/minElements.mjs';
2
2
 
3
- const extensionNameRegex = /.(\.[^./]+|\.)$/;
3
+ const extensionNameRegex = /\.([^./]+)$/;
4
4
  /**
5
5
  * {@include common/path/getExtensionName/index.md}
6
6
  */
7
7
  function getExtensionName(path) {
8
- if (path === "..") {
9
- return null;
10
- }
11
8
  const match = extensionNameRegex.exec(path);
12
9
  if (!!match && minElements(match, 2)) {
13
- if (match[1] === ".") {
14
- return null;
15
- }
16
10
  return match[1];
17
11
  }
18
12
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.4.41",
3
+ "version": "1.4.42",
4
4
  "author": {
5
5
  "name": "mathcovax",
6
6
  "url": "https://github.com/mathcovax"