cafe-utility 9.5.0 → 9.6.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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +4 -10
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -210,7 +210,7 @@ declare function getPreLine(string: string): string;
210
210
  declare function containsWord(string: string, word: string): boolean;
211
211
  declare function containsWords(string: string, words: string[]): boolean;
212
212
  declare function getCached<T>(key: string, ttlMillis: number, handler: () => Promise<T>): Promise<T>;
213
- declare function joinUrl(...parts: string[]): string;
213
+ declare function joinUrl(...parts: unknown[]): string;
214
214
  declare function sortObject<T>(object: CafeObject<T>): CafeObject<T>;
215
215
  declare function sortArray<T>(array: T[]): T[];
216
216
  declare function sortAny(any: unknown): unknown;
package/index.js CHANGED
@@ -1390,16 +1390,10 @@ async function getCached(key, ttlMillis, handler) {
1390
1390
  }
1391
1391
 
1392
1392
  function joinUrl(...parts) {
1393
- let url = parts[0][parts[0].length - 1] === '/' ? parts[0].slice(0, -1) : parts[0]
1394
- for (let i = 1; i < parts.length; i++) {
1395
- const part = parts[i]
1396
- if (part === '/') {
1397
- continue
1398
- }
1399
- const starts = part[0] === '/'
1400
- const ends = part[part.length - 1] === '/'
1401
- url += '/' + part.slice(starts ? 1 : 0, ends ? -1 : undefined)
1402
- }
1393
+ const url = parts
1394
+ .filter(part => part && isString(part))
1395
+ .join('/')
1396
+ .replace(/([^:]\/)\/+/g, '$1')
1403
1397
  return url
1404
1398
  }
1405
1399
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {