Skip to content

Commit

Permalink
Fixes #804: ensure POSIX-style remains in datapackage resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mulholland committed Jul 5, 2018
1 parent 26cfcb8 commit 19e9be1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/renderer/frictionlessDataPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '\\', '/')
}
4 changes: 2 additions & 2 deletions src/renderer/importPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19e9be1

Please sign in to comment.