-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't split paths on
^
characters (#192)
* fix: don't split paths on `^` characters * chore: add unit tests for toPathComponents util fn * chore: fix lint issues
- Loading branch information
1 parent
f5d3a67
commit 9a69908
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { expect } from 'aegir/utils/chai.js' | ||
import toPathComponents from '../src/utils/to-path-components.js' | ||
|
||
describe('toPathComponents', () => { | ||
it('splits on unescaped "/" characters', () => { | ||
const path = 'foo/bar/baz' | ||
const components = toPathComponents(path) | ||
expect(components.length).to.eq(3) | ||
}) | ||
|
||
it('does not split on escaped "/" characters', () => { | ||
const path = 'foo\\/bar/baz' | ||
const components = toPathComponents(path) | ||
expect(components.length).to.eq(2) | ||
}) | ||
|
||
// see https://github.com/ipfs/js-ipfs-unixfs/issues/177 for context | ||
it('does not split on "^" characters', () => { | ||
const path = 'foo/bar^baz^^qux' | ||
const components = toPathComponents(path) | ||
expect(components.length).to.eq(2) | ||
}) | ||
}) |