Skip to content

Commit

Permalink
fix: conform path paths for crossplatform compatibility (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored Apr 1, 2023
1 parent 9a242a2 commit 0f66f55
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/application/utils/conform-file-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import path from "path";

export const conformFilePath = (filePath = "") =>
filePath
.split(process.platform === "win32" ? path.posix.sep : path.win32.sep)
.join(path.sep);
6 changes: 5 additions & 1 deletion src/application/worker/store/modules/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Vue from "vue";
import { v4 as uuidv4 } from "uuid";

import store from "../";
import { conformFilePath } from "../../../utils/conform-file-path";

const state = {};

Expand All @@ -19,7 +20,10 @@ const actions = {
let joinedFilePath;

try {
joinedFilePath = path.join(store.state.media.path, filePath);
joinedFilePath = path.join(
store.state.media.path,
conformFilePath(filePath)
);
} catch (e) {
console.log(e);
}
Expand Down
11 changes: 8 additions & 3 deletions src/application/worker/store/modules/videos.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Vue from "vue";
import uuidv4 from "uuid/v4";
import { v4 as uuidv4 } from "uuid";
import path from "path";
import store from "../";
import { conformFilePath } from "../../../utils/conform-file-path";

const state = {};

Expand All @@ -12,10 +14,13 @@ const actions = {
createVideoFromPath({ rootState, commit }, textureDefinition) {
const {
id = uuidv4(),
options: { path }
options: { path: filePath }
} = textureDefinition;

const url = `modv://${rootState.media.path}${path}`;
const url = `modv://${path.join(
rootState.media.path,
conformFilePath(filePath)
)}`;

if (typeof window !== "undefined") {
self.postMessage({
Expand Down
9 changes: 7 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.13.tgz#5b2dd21cae4a2c5145f1fbd8ca103f9313d3b7e4"
integrity sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==

"@babel/parser@^7.18.4":
version "7.21.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.4.tgz#94003fdfc520bbe2875d4ae557b43ddb6d880f17"
integrity sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==

"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.0":
version "7.16.2"
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"
Expand Down Expand Up @@ -13814,7 +13819,7 @@ vue-template-babel-compiler@^2.0.0:
"@babel/types" "^7.14.5"
deepmerge "^4.2.2"

[email protected]:
vue-template-compiler@^2.7.14:
version "2.7.14"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz#4545b7dfb88090744c1577ae5ac3f964e61634b1"
integrity sha512-zyA5Y3ArvVG0NacJDkkzJuPQDF8RFeRlzV2vLeSnhSpieO6LK2OVbdLPi5MPPs09Ii+gMO8nY4S3iKQxBxDmWQ==
Expand All @@ -13827,7 +13832,7 @@ vue-template-es2015-compiler@^1.9.0:
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==

[email protected]:
vue@^2.7.14:
version "2.7.14"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.7.14.tgz#3743dcd248fd3a34d421ae456b864a0246bafb17"
integrity sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==
Expand Down

0 comments on commit 0f66f55

Please sign in to comment.