From db020963bfa1ace878c7696e75d85258dbbe9736 Mon Sep 17 00:00:00 2001 From: mattRedBox Date: Thu, 5 Jul 2018 10:05:11 +1000 Subject: [PATCH] Fixes #804: must have POSIX-path in resources. --- src/renderer/frictionlessDataPackage.js | 4 +++- src/renderer/importPackage.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/frictionlessDataPackage.js b/src/renderer/frictionlessDataPackage.js index 5d4350a38..bf7d538c5 100644 --- a/src/renderer/frictionlessDataPackage.js +++ b/src/renderer/frictionlessDataPackage.js @@ -251,5 +251,7 @@ function addPath(descriptor, tabId) { let parent = 'data' let filename = tabStore.state.tabObjects[tabId].filename let basename = path.basename(filename) - descriptor.path = path.join(parent, basename) + let osPath = path.join(parent, basename) + // resource paths must be POSIX https://frictionlessdata.io/specs/data-resource/#url-or-path + descriptor.path = _.replace(osPath, '\\', '/') } diff --git a/src/renderer/importPackage.js b/src/renderer/importPackage.js index f441fc01c..80a035385 100644 --- a/src/renderer/importPackage.js +++ b/src/renderer/importPackage.js @@ -170,8 +170,8 @@ async function getHotIdsFromFilenames(processed, unzipDestination, isTransient = throw new Error(`There was a problem matching ${fileDestination} with an opened tab.`) } let hotId = _.findKey(store.getters.getHotTabs, {tabId: tabId}) - // ensure csv path accounts for parent folders zipped up and windows path separator (as same as regexp escape) - const regExpPathSeparator = path.sep === '/' ? path.sep : path.sep + path.sep + // ensure csv path accounts for parent folders within zip - paths must be POSIX-only https://frictionlessdata.io/specs/data-resource/#url-or-path + const regExpPathSeparator = '/' let re = new RegExp('^' + processed.parentFolders + regExpPathSeparator) let resourcePathname = _.replace(pathname, re, '') csvTabs[`${resourcePathname}`] = hotId