modern-tar 0.7.4 → 0.7.5
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/dist/fs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as normalizeBody, c as LINK, l as SYMLINK, n as createTarPacker, o as DIRECTORY, r as transformHeader, s as FILE, t as createUnpacker } from "../unpacker-
|
|
1
|
+
import { a as normalizeBody, c as LINK, l as SYMLINK, n as createTarPacker, o as DIRECTORY, r as transformHeader, s as FILE, t as createUnpacker } from "../unpacker-Dcww6JeE.js";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import { cpus } from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
@@ -120,18 +120,24 @@ async function normalizeBody(body) {
|
|
|
120
120
|
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region src/tar/options.ts
|
|
123
|
+
const stripPath = (p, n) => {
|
|
124
|
+
const parts = p.split("/").filter(Boolean);
|
|
125
|
+
return n >= parts.length ? "" : parts.slice(n).join("/");
|
|
126
|
+
};
|
|
123
127
|
function transformHeader(header, options) {
|
|
124
128
|
const { strip, filter, map } = options;
|
|
125
129
|
if (!strip && !filter && !map) return header;
|
|
126
130
|
const h = { ...header };
|
|
127
131
|
if (strip && strip > 0) {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const newName = components.slice(strip).join("/");
|
|
132
|
+
const newName = stripPath(h.name, strip);
|
|
133
|
+
if (!newName) return null;
|
|
131
134
|
h.name = h.type === DIRECTORY && !newName.endsWith("/") ? `${newName}/` : newName;
|
|
132
|
-
if (h.linkname
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
+
if (h.linkname) {
|
|
136
|
+
const isAbsolute = h.linkname.startsWith("/");
|
|
137
|
+
if (isAbsolute || h.type === LINK) {
|
|
138
|
+
const stripped = stripPath(h.linkname, strip);
|
|
139
|
+
h.linkname = isAbsolute ? `/${stripped}` || "/" : stripped;
|
|
140
|
+
}
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
143
|
if (filter?.(h) === false) return null;
|
package/dist/web/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as normalizeBody, i as isBodyless, n as createTarPacker$1, r as transformHeader, t as createUnpacker } from "../unpacker-
|
|
1
|
+
import { a as normalizeBody, i as isBodyless, n as createTarPacker$1, r as transformHeader, t as createUnpacker } from "../unpacker-Dcww6JeE.js";
|
|
2
2
|
|
|
3
3
|
//#region src/web/compression.ts
|
|
4
4
|
function createGzipEncoder() {
|