incyclist-services 1.9.37 → 1.9.38

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,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeFileUrl = void 0;
3
+ exports.isWindows = exports.normalizeFileUrl = void 0;
4
4
  const api_1 = require("../api");
5
5
  const normalizeFileUrl = (url) => {
6
- if (!isWindows())
6
+ if (!(0, exports.isWindows)())
7
7
  return url;
8
8
  return url?.replace(/^(file|video):\/\/+(?=[A-Za-z]:(?:[\\/%]|$))/, '$1:///');
9
9
  };
10
10
  exports.normalizeFileUrl = normalizeFileUrl;
11
11
  const isWindows = () => (0, api_1.getBindings)().appInfo?.getOS?.()?.platform === 'win32';
12
+ exports.isWindows = isWindows;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolvePlaybackUrl = void 0;
4
+ const fileurl_1 = require("../utils/fileurl");
4
5
  const resolvePlaybackUrl = (url) => {
5
6
  if (!url)
6
7
  return undefined;
@@ -9,13 +10,20 @@ const resolvePlaybackUrl = (url) => {
9
10
  if (fileName.startsWith('incyclist:'))
10
11
  fileName = fileName.replace('incyclist:', 'file:');
11
12
  if (fileName.startsWith('video:') && !lc.endsWith('.avi'))
12
- return fileName.replace('video:', 'file:');
13
+ return restoreWindowsSeparators(fileName.replace('video:', 'file:'));
13
14
  if (fileName.startsWith('video:') && lc.endsWith('.avi'))
14
15
  return fileName;
15
- if (fileName.startsWith('file:') || fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
16
+ if (fileName.startsWith('file:'))
17
+ return restoreWindowsSeparators(fileName);
18
+ if (fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
16
19
  return fileName;
17
20
  if (fileName.startsWith('content:'))
18
21
  return fileName;
19
22
  return `./${fileName}`;
20
23
  };
21
24
  exports.resolvePlaybackUrl = resolvePlaybackUrl;
25
+ const restoreWindowsSeparators = (url) => {
26
+ if (!(0, fileurl_1.isWindows)() || !/^file:\/\/\/[A-Za-z]:/.test(url))
27
+ return url;
28
+ return url.replace(/%5C/gi, '\\');
29
+ };
@@ -4,4 +4,4 @@ export const normalizeFileUrl = (url) => {
4
4
  return url;
5
5
  return url?.replace(/^(file|video):\/\/+(?=[A-Za-z]:(?:[\\/%]|$))/, '$1:///');
6
6
  };
7
- const isWindows = () => getBindings().appInfo?.getOS?.()?.platform === 'win32';
7
+ export const isWindows = () => getBindings().appInfo?.getOS?.()?.platform === 'win32';
@@ -1,3 +1,4 @@
1
+ import { isWindows } from '../utils/fileurl';
1
2
  export const resolvePlaybackUrl = (url) => {
2
3
  if (!url)
3
4
  return undefined;
@@ -6,12 +7,19 @@ export const resolvePlaybackUrl = (url) => {
6
7
  if (fileName.startsWith('incyclist:'))
7
8
  fileName = fileName.replace('incyclist:', 'file:');
8
9
  if (fileName.startsWith('video:') && !lc.endsWith('.avi'))
9
- return fileName.replace('video:', 'file:');
10
+ return restoreWindowsSeparators(fileName.replace('video:', 'file:'));
10
11
  if (fileName.startsWith('video:') && lc.endsWith('.avi'))
11
12
  return fileName;
12
- if (fileName.startsWith('file:') || fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
13
+ if (fileName.startsWith('file:'))
14
+ return restoreWindowsSeparators(fileName);
15
+ if (fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
13
16
  return fileName;
14
17
  if (fileName.startsWith('content:'))
15
18
  return fileName;
16
19
  return `./${fileName}`;
17
20
  };
21
+ const restoreWindowsSeparators = (url) => {
22
+ if (!isWindows() || !/^file:\/\/\/[A-Za-z]:/.test(url))
23
+ return url;
24
+ return url.replace(/%5C/gi, '\\');
25
+ };
@@ -1 +1,2 @@
1
1
  export declare const normalizeFileUrl: (url?: string) => string | undefined;
2
+ export declare const isWindows: () => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.9.37",
3
+ "version": "1.9.38",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },