• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hexojs / hexo-util / 20649769741

02 Jan 2026 02:53AM UTC coverage: 94.992% (-0.3%) from 95.292%
20649769741

Pull #441

github

web-flow
Merge 7d51793f5 into ba23651c6
Pull Request #441: perf: faster `encode_url` and `decode_url`

470 of 489 branches covered (96.11%)

10 of 10 new or added lines in 2 files covered. (100.0%)

6 existing lines in 2 files now uncovered.

1783 of 1877 relevant lines covered (94.99%)

13.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/lib/encode_url.ts
1
// eslint-disable-next-line n/no-deprecated-api
1✔
2
import { parse, format } from 'url';
1✔
3
import { unescape } from 'querystring';
1✔
4

1✔
5
const encodeURL = (str: string) => {
1✔
6
  const index = str.indexOf(':');
100✔
7
  if (index < 0) {
100✔
8
    return encodeURI(unescape(str));
59✔
9
  }
59✔
10
  if (parse(str.slice(0, index + 1)).protocol) {
41✔
11
    const parsed = new URL(str);
41✔
12

41✔
13
    // Exit if input is a data url
41✔
14
    if (parsed.origin === 'null') return str;
41✔
15

40✔
16
    parsed.search = new URLSearchParams(parsed.search).toString();
40✔
17
    parsed.pathname = encodeURI(decodeURI(parsed.pathname));
40✔
18
    // preserve IDN
40✔
19
    return format(parsed, { unicode: true });
40✔
20
  }
40✔
UNCOV
21

×
UNCOV
22
  return encodeURI(unescape(str));
×
UNCOV
23
};
×
24

1✔
25
export = encodeURL;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc