Skip to content

Commit 0f66f55

Browse files
authored
fix: conform path paths for crossplatform compatibility (#835)
1 parent 9a242a2 commit 0f66f55

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import path from "path";
2+
3+
export const conformFilePath = (filePath = "") =>
4+
filePath
5+
.split(process.platform === "win32" ? path.posix.sep : path.win32.sep)
6+
.join(path.sep);

src/application/worker/store/modules/images.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Vue from "vue";
66
import { v4 as uuidv4 } from "uuid";
77

88
import store from "../";
9+
import { conformFilePath } from "../../../utils/conform-file-path";
910

1011
const state = {};
1112

@@ -19,7 +20,10 @@ const actions = {
1920
let joinedFilePath;
2021

2122
try {
22-
joinedFilePath = path.join(store.state.media.path, filePath);
23+
joinedFilePath = path.join(
24+
store.state.media.path,
25+
conformFilePath(filePath)
26+
);
2327
} catch (e) {
2428
console.log(e);
2529
}

src/application/worker/store/modules/videos.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Vue from "vue";
2-
import uuidv4 from "uuid/v4";
2+
import { v4 as uuidv4 } from "uuid";
3+
import path from "path";
34
import store from "../";
5+
import { conformFilePath } from "../../../utils/conform-file-path";
46

57
const state = {};
68

@@ -12,10 +14,13 @@ const actions = {
1214
createVideoFromPath({ rootState, commit }, textureDefinition) {
1315
const {
1416
id = uuidv4(),
15-
options: { path }
17+
options: { path: filePath }
1618
} = textureDefinition;
1719

18-
const url = `modv://${rootState.media.path}${path}`;
20+
const url = `modv://${path.join(
21+
rootState.media.path,
22+
conformFilePath(filePath)
23+
)}`;
1924

2025
if (typeof window !== "undefined") {
2126
self.postMessage({

yarn.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@
502502
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.13.tgz#5b2dd21cae4a2c5145f1fbd8ca103f9313d3b7e4"
503503
integrity sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==
504504

505+
"@babel/parser@^7.18.4":
506+
version "7.21.4"
507+
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.4.tgz#94003fdfc520bbe2875d4ae557b43ddb6d880f17"
508+
integrity sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==
509+
505510
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.0":
506511
version "7.16.2"
507512
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.2.tgz#2977fca9b212db153c195674e57cfab807733183"
@@ -13814,7 +13819,7 @@ vue-template-babel-compiler@^2.0.0:
1381413819
"@babel/types" "^7.14.5"
1381513820
deepmerge "^4.2.2"
1381613821

13817-
vue-template-compiler@2.7.14:
13822+
vue-template-compiler@^2.7.14:
1381813823
version "2.7.14"
1381913824
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz#4545b7dfb88090744c1577ae5ac3f964e61634b1"
1382013825
integrity sha512-zyA5Y3ArvVG0NacJDkkzJuPQDF8RFeRlzV2vLeSnhSpieO6LK2OVbdLPi5MPPs09Ii+gMO8nY4S3iKQxBxDmWQ==
@@ -13827,7 +13832,7 @@ vue-template-es2015-compiler@^1.9.0:
1382713832
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
1382813833
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==
1382913834

13830-
vue@2.7.14:
13835+
vue@^2.7.14:
1383113836
version "2.7.14"
1383213837
resolved "https://registry.yarnpkg.com/vue/-/vue-2.7.14.tgz#3743dcd248fd3a34d421ae456b864a0246bafb17"
1383313838
integrity sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==

0 commit comments

Comments
 (0)