@flystorage/file-storage 1.2.0 → 1.2.2

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.
@@ -1,15 +1,27 @@
1
1
  # `@flystorage/file-storage`
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Fixes
6
+
7
+ - Fixed typo in timeout options name
8
+
9
+ ## 1.2.1
10
+
11
+ ### Fixes
12
+
13
+ - Prevent unprefixed root paths to become '/' for directory listings.
14
+
3
15
  ## 1.2.0
4
16
 
5
- ## Added
17
+ ### Added
6
18
 
7
19
  - Ability to ignore visibility using configuration
8
20
  - Support Bun runtime
9
21
 
10
22
  ## 1.1.0
11
23
 
12
- ## Added
24
+ ### Added
13
25
 
14
26
  - AbortSignal Support
15
27
  - Normalised over stream errors for reads
@@ -6,7 +6,7 @@ class PathPrefixer {
6
6
  separator;
7
7
  joinFunc;
8
8
  prefix = '';
9
- constructor(prefix = '', separator = '/', joinFunc = node_path_1.join) {
9
+ constructor(prefix = '', separator = '/', joinFunc = node_path_1.posix.join) {
10
10
  this.separator = separator;
11
11
  this.joinFunc = joinFunc;
12
12
  if (prefix.length > 0) {
@@ -17,7 +17,13 @@ class PathPrefixer {
17
17
  return this.prefix.length > 0 ? this.joinFunc(this.prefix, path) : path;
18
18
  }
19
19
  prefixDirectoryPath(path) {
20
- return this.prefix.length > 0 ? this.joinFunc(this.prefix, path, '/') : this.joinFunc(path, '/');
20
+ let fullPath = this.prefix.length > 0
21
+ ? this.joinFunc(this.prefix, path)
22
+ : path;
23
+ if (fullPath.length > 0 && !fullPath.endsWith(this.separator)) {
24
+ fullPath = `${fullPath}${this.separator}`;
25
+ }
26
+ return fullPath;
21
27
  }
22
28
  stripFilePath(path) {
23
29
  return path.substring(this.prefix.length);
@@ -1,9 +1,9 @@
1
- import { join } from 'node:path';
1
+ import { posix } from 'node:path';
2
2
  export class PathPrefixer {
3
3
  separator;
4
4
  joinFunc;
5
5
  prefix = '';
6
- constructor(prefix = '', separator = '/', joinFunc = join) {
6
+ constructor(prefix = '', separator = '/', joinFunc = posix.join) {
7
7
  this.separator = separator;
8
8
  this.joinFunc = joinFunc;
9
9
  if (prefix.length > 0) {
@@ -14,7 +14,13 @@ export class PathPrefixer {
14
14
  return this.prefix.length > 0 ? this.joinFunc(this.prefix, path) : path;
15
15
  }
16
16
  prefixDirectoryPath(path) {
17
- return this.prefix.length > 0 ? this.joinFunc(this.prefix, path, '/') : this.joinFunc(path, '/');
17
+ let fullPath = this.prefix.length > 0
18
+ ? this.joinFunc(this.prefix, path)
19
+ : path;
20
+ if (fullPath.length > 0 && !fullPath.endsWith(this.separator)) {
21
+ fullPath = `${fullPath}${this.separator}`;
22
+ }
23
+ return fullPath;
18
24
  }
19
25
  stripFilePath(path) {
20
26
  return path.substring(this.prefix.length);
@@ -57,7 +57,7 @@ export declare class DirectoryListing implements AsyncIterable<StatEntry> {
57
57
  }
58
58
  export type FileContents = Iterable<any> | AsyncIterable<any> | NodeJS.ReadableStream | Readable | string;
59
59
  export type TimeoutOptions = {
60
- timout?: number;
60
+ timeout?: number;
61
61
  };
62
62
  export type MiscellaneousOptions = TimeoutOptions & {
63
63
  [option: string]: any;
@@ -1,4 +1,4 @@
1
- import { join } from 'node:path';
1
+ import { type join } from 'node:path';
2
2
  export declare class PathPrefixer {
3
3
  private readonly separator;
4
4
  private readonly joinFunc;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flystorage/file-storage",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "description": "File-storage abstraction: multiple filesystems, one API.",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "types": "./dist/types/index.d.ts",