Skip to content

Commit

Permalink
fix: support unicode paths, closes #27
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Mahon <[email protected]>
  • Loading branch information
danielmahon committed Aug 25, 2020
1 parent fb63dd3 commit 31f432e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"cheerio": "1.0.0-rc.3",
"is-relative-url": "3.0.0",
"lodash": "4.17.20",
"slash": "3.0.0",
"traverse": "0.6.6",
"unist-util-select": "3.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { selectAll } from 'unist-util-select';
import isRelativeUrl from 'is-relative-url';
import { defaults, isString, find, some } from 'lodash';
import cheerio from 'cheerio';
import slash from 'slash';
import traverse from 'traverse';
import { slash } from './utils';

export type GatsbyNodePluginArgs = {
files: GatsbyNode[];
Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const slash = (path: string): string => {
const isExtendedLengthPath = /^\\\\\?\\/.test(path);

if (isExtendedLengthPath) {
return path;
}
return path.replace(/\\/g, `/`);
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ safe-buffer@~5.2.0:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

slash@*, [email protected]:
slash@*:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
Expand Down

0 comments on commit 31f432e

Please sign in to comment.