@cratis/arc 22.27.1 → 22.28.0

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,2 +1,2 @@
1
- export declare function joinPaths(...paths: any[]): string;
1
+ export declare function joinPaths(...paths: string[]): string;
2
2
  //# sourceMappingURL=joinPaths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"joinPaths.d.ts","sourceRoot":"","sources":["../../joinPaths.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,GAAG,KAAK,OAAA,UAGjC"}
1
+ {"version":3,"file":"joinPaths.d.ts","sourceRoot":"","sources":["../../joinPaths.ts"],"names":[],"mappings":"AAmBA,wBAAgB,SAAS,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQpD"}
@@ -2,9 +2,28 @@
2
2
 
3
3
  // Copyright (c) Cratis. All rights reserved.
4
4
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ function trimTrailingSlashes(path) {
6
+ let end = path.length;
7
+ while(end > 0 && path[end - 1] === '/'){
8
+ end--;
9
+ }
10
+ return path.slice(0, end);
11
+ }
12
+ function trimLeadingSlashes(path) {
13
+ let start = 0;
14
+ while(start < path.length && path[start] === '/'){
15
+ start++;
16
+ }
17
+ return path.slice(start);
18
+ }
5
19
  function joinPaths(...paths) {
6
- const joined = paths.join('/');
7
- return joined.replace('//', '/');
20
+ let joined = paths[0] ?? '';
21
+ for (const path of paths.slice(1)){
22
+ const base = joined.endsWith('://') ? joined : trimTrailingSlashes(joined);
23
+ const segment = trimLeadingSlashes(path);
24
+ joined = `${base}${base.endsWith('://') ? '' : '/'}${segment}`;
25
+ }
26
+ return joined;
8
27
  }
9
28
 
10
29
  exports.joinPaths = joinPaths;
@@ -1 +1 @@
1
- {"version":3,"file":"joinPaths.js","sources":["../../joinPaths.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport function joinPaths(...paths) {\n const joined = paths.join('/');\n return joined.replace('//', '/');\n}"],"names":["joinPaths","paths","joined","join","replace"],"mappings":";;AAAA;AACA;AAEO,SAASA,SAAAA,CAAU,GAAGC,KAAK,EAAA;IAC9B,MAAMC,MAAAA,GAASD,KAAAA,CAAME,IAAI,CAAC,GAAA,CAAA;IAC1B,OAAOD,MAAAA,CAAOE,OAAO,CAAC,IAAA,EAAM,GAAA,CAAA;AAChC;;"}
1
+ {"version":3,"file":"joinPaths.js","sources":["../../joinPaths.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nfunction trimTrailingSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path[end - 1] === '/') {\n end--;\n }\n return path.slice(0, end);\n}\n\nfunction trimLeadingSlashes(path: string): string {\n let start = 0;\n while (start < path.length && path[start] === '/') {\n start++;\n }\n return path.slice(start);\n}\n\nexport function joinPaths(...paths: string[]): string {\n let joined = paths[0] ?? '';\n for (const path of paths.slice(1)) {\n const base = joined.endsWith('://') ? joined : trimTrailingSlashes(joined);\n const segment = trimLeadingSlashes(path);\n joined = `${base}${base.endsWith('://') ? '' : '/'}${segment}`;\n }\n return joined;\n}\n"],"names":["trimTrailingSlashes","path","end","length","slice","trimLeadingSlashes","start","joinPaths","paths","joined","base","endsWith","segment"],"mappings":";;AAAA;AACA;AAEA,SAASA,oBAAoBC,IAAY,EAAA;IACrC,IAAIC,GAAAA,GAAMD,KAAKE,MAAM;AACrB,IAAA,MAAOD,MAAM,CAAA,IAAKD,IAAI,CAACC,GAAAA,GAAM,CAAA,CAAE,KAAK,GAAA,CAAK;AACrCA,QAAAA,GAAAA,EAAAA;AACJ,IAAA;IACA,OAAOD,IAAAA,CAAKG,KAAK,CAAC,CAAA,EAAGF,GAAAA,CAAAA;AACzB;AAEA,SAASG,mBAAmBJ,IAAY,EAAA;AACpC,IAAA,IAAIK,KAAAA,GAAQ,CAAA;IACZ,MAAOA,KAAAA,GAAQL,KAAKE,MAAM,IAAIF,IAAI,CAACK,KAAAA,CAAM,KAAK,GAAA,CAAK;AAC/CA,QAAAA,KAAAA,EAAAA;AACJ,IAAA;IACA,OAAOL,IAAAA,CAAKG,KAAK,CAACE,KAAAA,CAAAA;AACtB;AAEO,SAASC,SAAAA,CAAU,GAAGC,KAAe,EAAA;AACxC,IAAA,IAAIC,MAAAA,GAASD,KAAK,CAAC,CAAA,CAAE,IAAI,EAAA;AACzB,IAAA,KAAK,MAAMP,IAAAA,IAAQO,KAAAA,CAAMJ,KAAK,CAAC,CAAA,CAAA,CAAI;AAC/B,QAAA,MAAMM,OAAOD,MAAAA,CAAOE,QAAQ,CAAC,KAAA,CAAA,GAASF,SAAST,mBAAAA,CAAoBS,MAAAA,CAAAA;AACnE,QAAA,MAAMG,UAAUP,kBAAAA,CAAmBJ,IAAAA,CAAAA;QACnCQ,MAAAA,GAAS,CAAA,EAAGC,OAAOA,IAAAA,CAAKC,QAAQ,CAAC,KAAA,CAAA,GAAS,EAAA,GAAK,MAAMC,OAAAA,CAAAA,CAAS;AAClE,IAAA;IACA,OAAOH,MAAAA;AACX;;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_joining_paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_joining_paths.d.ts","sourceRoot":"","sources":["../../../for_joinPaths/when_joining_paths.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { joinPaths } from '../joinPaths.js';
2
+ describe('when joining paths', () => {
3
+ it('should join ordinary segments', () => joinPaths('api', 'orders').should.equal('api/orders'));
4
+ it('should preserve a leading slash', () => joinPaths('/workbench', 'api').should.equal('/workbench/api'));
5
+ it('should collapse repeated slashes at each boundary', () => joinPaths('/workbench//', '///api//', '//orders').should.equal('/workbench/api/orders'));
6
+ it('should leave slashes within a segment alone', () => joinPaths('/a//b', 'c//d').should.equal('/a//b/c//d'));
7
+ it('should preserve an https scheme', () => joinPaths('https://example.com/', '/api').should.equal('https://example.com/api'));
8
+ it('should preserve an http scheme', () => joinPaths('http://example.com', '/api').should.equal('http://example.com/api'));
9
+ it('should preserve a scheme supplied as its own segment', () => joinPaths('https://', 'example.com', '/api').should.equal('https://example.com/api'));
10
+ it('should handle an empty first segment', () => joinPaths('', '/api').should.equal('/api'));
11
+ it('should handle empty middle segments', () => joinPaths('/api', '', 'orders').should.equal('/api/orders'));
12
+ it('should preserve the separator between two empty segments', () => joinPaths('', '').should.equal('/'));
13
+ it('should handle no segments', () => joinPaths().should.equal(''));
14
+ it('should preserve a trailing slash', () => joinPaths('/api/', 'orders/').should.equal('/api/orders/'));
15
+ it('should preserve a trailing slash for an empty final segment', () => joinPaths('/api', '').should.equal('/api/'));
16
+ });
17
+ //# sourceMappingURL=when_joining_paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_joining_paths.js","sourceRoot":"","sources":["../../../for_joinPaths/when_joining_paths.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IACjG,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3G,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACvJ,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,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CAAC,6DAA6D,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACzH,CAAC,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function joinPaths(...paths: any[]): string;
1
+ export declare function joinPaths(...paths: string[]): string;
2
2
  //# sourceMappingURL=joinPaths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"joinPaths.d.ts","sourceRoot":"","sources":["../../joinPaths.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,GAAG,KAAK,OAAA,UAGjC"}
1
+ {"version":3,"file":"joinPaths.d.ts","sourceRoot":"","sources":["../../joinPaths.ts"],"names":[],"mappings":"AAmBA,wBAAgB,SAAS,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQpD"}
@@ -1,8 +1,27 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ function trimTrailingSlashes(path) {
4
+ let end = path.length;
5
+ while(end > 0 && path[end - 1] === '/'){
6
+ end--;
7
+ }
8
+ return path.slice(0, end);
9
+ }
10
+ function trimLeadingSlashes(path) {
11
+ let start = 0;
12
+ while(start < path.length && path[start] === '/'){
13
+ start++;
14
+ }
15
+ return path.slice(start);
16
+ }
3
17
  function joinPaths(...paths) {
4
- const joined = paths.join('/');
5
- return joined.replace('//', '/');
18
+ let joined = paths[0] ?? '';
19
+ for (const path of paths.slice(1)){
20
+ const base = joined.endsWith('://') ? joined : trimTrailingSlashes(joined);
21
+ const segment = trimLeadingSlashes(path);
22
+ joined = `${base}${base.endsWith('://') ? '' : '/'}${segment}`;
23
+ }
24
+ return joined;
6
25
  }
7
26
 
8
27
  export { joinPaths };
@@ -1 +1 @@
1
- {"version":3,"file":"joinPaths.js","sources":["../../joinPaths.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport function joinPaths(...paths) {\n const joined = paths.join('/');\n return joined.replace('//', '/');\n}"],"names":["joinPaths","paths","joined","join","replace"],"mappings":"AAAA;AACA;AAEO,SAASA,SAAAA,CAAU,GAAGC,KAAK,EAAA;IAC9B,MAAMC,MAAAA,GAASD,KAAAA,CAAME,IAAI,CAAC,GAAA,CAAA;IAC1B,OAAOD,MAAAA,CAAOE,OAAO,CAAC,IAAA,EAAM,GAAA,CAAA;AAChC;;"}
1
+ {"version":3,"file":"joinPaths.js","sources":["../../joinPaths.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nfunction trimTrailingSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path[end - 1] === '/') {\n end--;\n }\n return path.slice(0, end);\n}\n\nfunction trimLeadingSlashes(path: string): string {\n let start = 0;\n while (start < path.length && path[start] === '/') {\n start++;\n }\n return path.slice(start);\n}\n\nexport function joinPaths(...paths: string[]): string {\n let joined = paths[0] ?? '';\n for (const path of paths.slice(1)) {\n const base = joined.endsWith('://') ? joined : trimTrailingSlashes(joined);\n const segment = trimLeadingSlashes(path);\n joined = `${base}${base.endsWith('://') ? '' : '/'}${segment}`;\n }\n return joined;\n}\n"],"names":["trimTrailingSlashes","path","end","length","slice","trimLeadingSlashes","start","joinPaths","paths","joined","base","endsWith","segment"],"mappings":"AAAA;AACA;AAEA,SAASA,oBAAoBC,IAAY,EAAA;IACrC,IAAIC,GAAAA,GAAMD,KAAKE,MAAM;AACrB,IAAA,MAAOD,MAAM,CAAA,IAAKD,IAAI,CAACC,GAAAA,GAAM,CAAA,CAAE,KAAK,GAAA,CAAK;AACrCA,QAAAA,GAAAA,EAAAA;AACJ,IAAA;IACA,OAAOD,IAAAA,CAAKG,KAAK,CAAC,CAAA,EAAGF,GAAAA,CAAAA;AACzB;AAEA,SAASG,mBAAmBJ,IAAY,EAAA;AACpC,IAAA,IAAIK,KAAAA,GAAQ,CAAA;IACZ,MAAOA,KAAAA,GAAQL,KAAKE,MAAM,IAAIF,IAAI,CAACK,KAAAA,CAAM,KAAK,GAAA,CAAK;AAC/CA,QAAAA,KAAAA,EAAAA;AACJ,IAAA;IACA,OAAOL,IAAAA,CAAKG,KAAK,CAACE,KAAAA,CAAAA;AACtB;AAEO,SAASC,SAAAA,CAAU,GAAGC,KAAe,EAAA;AACxC,IAAA,IAAIC,MAAAA,GAASD,KAAK,CAAC,CAAA,CAAE,IAAI,EAAA;AACzB,IAAA,KAAK,MAAMP,IAAAA,IAAQO,KAAAA,CAAMJ,KAAK,CAAC,CAAA,CAAA,CAAI;AAC/B,QAAA,MAAMM,OAAOD,MAAAA,CAAOE,QAAQ,CAAC,KAAA,CAAA,GAASF,SAAST,mBAAAA,CAAoBS,MAAAA,CAAAA;AACnE,QAAA,MAAMG,UAAUP,kBAAAA,CAAmBJ,IAAAA,CAAAA;QACnCQ,MAAAA,GAAS,CAAA,EAAGC,OAAOA,IAAAA,CAAKC,QAAQ,CAAC,KAAA,CAAA,GAAS,EAAA,GAAK,MAAMC,OAAAA,CAAAA,CAAS;AAClE,IAAA;IACA,OAAOH,MAAAA;AACX;;"}