@flystorage/file-storage 1.2.0 → 1.2.1

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/changelog.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## 1.2.0
4
4
 
5
- ## Added
5
+ ### Added
6
6
 
7
7
  - Ability to ignore visibility using configuration
8
8
  - Support Bun runtime
9
9
 
10
10
  ## 1.1.0
11
11
 
12
- ## Added
12
+ ### Added
13
13
 
14
14
  - AbortSignal Support
15
15
  - 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);
@@ -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.1",
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",