Skip to content

Commit 6b1fdea

Browse files
committed
catch URI malformed error
1 parent f2d5b01 commit 6b1fdea

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/plugins/validators/sync/00_validateLink.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ export default {
2929
const isProtocolless = /^\/\//.test(link.href);
3030

3131
const href = urlLib.resolve(url, link.href);
32-
if (link.href !== href
33-
// Spaces in direct image srcs are replaced with "%20"
34-
// in `urlLib.resolve(url, link.href)`
35-
&& decodeURIComponent(link.href) !== decodeURIComponent(href)
36-
) {
37-
link.href = href;
32+
try {
33+
if (link.href !== href
34+
// Spaces in direct image srcs are replaced with "%20"
35+
// in `urlLib.resolve(url, link.href)`
36+
&& decodeURIComponent(link.href) !== decodeURIComponent(href)
37+
) {
38+
link.href = href;
39+
}
40+
} catch(ex) {
41+
// URI malformed.
3842
}
3943

40-
4144
const domainRE = /^(?:https?:)?\/\/([^\/]+)\//;
4245
var urlDomainMatch, linkDomainMatch;
4346
// But undo protocol resolution when it forces HTTP or domains do not match.
@@ -93,4 +96,4 @@ export default {
9396
// Defined && unique values.
9497
link.rel = [...new Set(link.rel)];
9598
}
96-
};
99+
};

0 commit comments

Comments
 (0)