Skip to content

Commit c7118d7

Browse files
committed
refactor: merge safeDecode and safeHref into one
didn't notice safeDecode was only used in isCustomLink
1 parent 365b3ea commit c7118d7

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

index.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,6 @@ function shortenRepoUrl(href, currentUrl = 'https://github.com') {
290290
* @type {(url: string) => string}
291291
*/
292292
function safeDecode(url) {
293-
try {
294-
return decodeURIComponent(url);
295-
} catch {
296-
return url;
297-
}
298-
}
299-
300-
/**
301-
* Handle non-URL gracefully
302-
* @type {(url: string) => string}
303-
*/
304-
function safeHref(url) {
305293
try {
306294
return new URL(url).href;
307295
} catch {
@@ -316,8 +304,8 @@ function getLinkHref(a) {
316304

317305
/** @param a {HTMLAnchorElement} */
318306
function isCustomLink(a) {
319-
const url = safeHref(getLinkHref(a));
320-
const label = safeHref(a.textContent);
307+
const url = safeDecode(getLinkHref(a));
308+
const label = safeDecode(a.textContent);
321309
return (
322310
// `trim` makes it compatible with this feature: https://github.com/sindresorhus/refined-github/pull/3085
323311
url !== label.trim()

0 commit comments

Comments
 (0)