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

hexojs / hexo-util / 16651986209

31 Jul 2025 02:35PM UTC coverage: 73.036% (-23.8%) from 96.875%
16651986209

Pull #426

github

web-flow
Merge e24598988 into d497bc760
Pull Request #426: build: restructure for dual ESM/CJS output, update tooling, and enhance utilities

811 of 1128 branches covered (71.9%)

1594 of 2028 new or added lines in 40 files covered. (78.6%)

6 existing lines in 1 file now uncovered.

5290 of 7243 relevant lines covered (73.04%)

69.13 hits per line

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

95.56
/lib/full_url_for.ts
1
import encodeURL from './encode_url.js';
2✔
2
import prettyUrls from './pretty_urls.js';
2✔
3
import Cache from './cache.js';
2✔
4
const cache = new Cache<string>();
2✔
5

2✔
6
export function fullUrlForHelper(path = '/') {
2✔
7
  // Safe destructuring to avoid errors if `this` is undefined
20✔
8
  const { config = {} } = this || {};
20!
9
  const prettyUrlsOptions = Object.assign({
20✔
10
    trailing_index: true,
20✔
11
    trailing_html: true
20✔
12
  }, config.pretty_urls);
20✔
13

20✔
14
  // cacheId is designed to works across different hexo.config & options
20✔
15
  return cache.apply(`${config.url}-${prettyUrlsOptions.trailing_index}-${prettyUrlsOptions.trailing_html}-${path}`, () => {
20✔
16
    if (/^(\/\/|http(s)?:)/.test(path)) return path;
20✔
17

15✔
18

15✔
19
    let sitehost = '';
15✔
20
    try {
15✔
21
      sitehost = new URL(config.url).hostname;
15✔
22
    } catch {
20!
NEW
23
      sitehost = config.url;
×
NEW
24
    }
×
25
    const data = new URL(path, `http://${sitehost}`);
15✔
26

15✔
27
    // Exit if input is an external link or a data url
15✔
28
    if (data.hostname !== sitehost || data.origin === 'null') return path;
20✔
29

13✔
30
    path = encodeURL(config.url + `/${path}`.replace(/\/{2,}/g, '/'));
13✔
31
    path = prettyUrls(path, prettyUrlsOptions);
13✔
32

13✔
33
    return path;
13✔
34
  });
20✔
35
}
20✔
36

2✔
37

2✔
38
// For ESM compatibility
2✔
39
export default fullUrlForHelper;
2✔
40
// For CommonJS compatibility
2✔
41
if (typeof module !== 'undefined' && typeof module.exports === 'object' && module.exports !== null) {
2!
42
  module.exports = fullUrlForHelper;
1✔
43
  // For ESM compatibility
1✔
44
  module.exports.default = fullUrlForHelper;
1✔
45
}
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

© 2025 Coveralls, Inc