Skip to content

Commit 460e5a0

Browse files
committed
fix(windows): support windows
1 parent 7081980 commit 460e5a0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/no-dead-link.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { RuleHelper } from 'textlint-rule-helper';
22
import fetch from 'isomorphic-fetch';
33
import URL from 'url';
44
import fs from 'fs-extra';
5+
import { isAbsolute } from 'path';
56

67
const DEFAULT_OPTIONS = {
78
checkRelative: true, // {boolean} `false` disables the checks for relative URIs
@@ -16,17 +17,23 @@ const URI_REGEXP = /(?:https?:)?\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z
1617
* Returns `true` if a given URI is relative.
1718
* @param {string} uri
1819
* @return {boolean}
20+
* @see https://github.com/panosoft/is-local-path
1921
*/
2022
function isRelative(uri) {
21-
return URL.parse(uri).protocol === null;
23+
const { host } = URL.parse(uri);
24+
return host === null || host === '';
2225
}
2326

2427
/**
2528
* Returns if a given URI indicates a local file.
2629
* @param {string} uri
2730
* @return {boolean}
31+
* @see https://nodejs.org/api/path.html#path_path_isabsolute_path
2832
*/
2933
function isLocal(uri) {
34+
if (isAbsolute(uri)) {
35+
return true;
36+
}
3037
return isRelative(uri);
3138
}
3239

0 commit comments

Comments
 (0)