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

next-theme / hexo-theme-next / 7071125284

02 Dec 2023 03:41PM UTC coverage: 97.416%. Remained the same
7071125284

push

github

web-flow
Update beian URL (#723)

96 of 104 branches covered (0.0%)

Branch coverage included in aggregate %.

394 of 399 relevant lines covered (98.75%)

3.66 hits per line

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

97.01
/scripts/helpers/next-url.js
1
'use strict';
1✔
2

1✔
3
const { htmlTag } = require('hexo-util');
1✔
4
const { parse } = require('url');
1✔
5

1✔
6
module.exports = function(path, text, options = {}, decode = false) {
1✔
7
  const { config, theme } = this;
7✔
8
  const data = parse(path);
7✔
9
  const siteHost = parse(config.url).hostname || config.url;
7!
10

7✔
11
  let exturl = '';
7✔
12
  let tag = 'a';
7✔
13
  let attrs = { href: this.url_for(path) };
7✔
14

7✔
15
  // If `exturl` enabled, set spanned links only on external links.
7✔
16
  if (theme.exturl && data.protocol && data.hostname !== siteHost) {
7✔
17
    tag = 'span';
2✔
18
    exturl = 'exturl';
2✔
19
    const encoded = Buffer.from(path).toString('base64');
2✔
20
    attrs = {
2✔
21
      class     : exturl,
2✔
22
      'data-url': encoded
2✔
23
    };
2✔
24
  }
2✔
25

7✔
26
  for (const key in options) {
7✔
27

2✔
28
    /**
2✔
29
     * If option have `class` attribute, add it to
2✔
30
     * 'exturl' class if `exturl` option enabled.
2✔
31
     */
2✔
32
    if (exturl !== '' && key === 'class') {
2✔
33
      attrs[key] += ' ' + options[key];
1✔
34
    } else {
1✔
35
      attrs[key] = options[key];
1✔
36
    }
1✔
37
  }
2✔
38

7✔
39
  // If it's external link, rewrite attributes.
7✔
40
  if (data.protocol && data.hostname !== siteHost) {
7✔
41
    attrs.external = null;
4✔
42

4✔
43
    if (!theme.exturl) {
4✔
44
      // Only for simple link need to rewrite/add attributes.
2✔
45
      attrs.rel = attrs.rel || 'noopener';
2✔
46
      attrs.target = '_blank';
2✔
47
    } else {
2✔
48
      // Remove rel attributes for `exturl` in main menu.
2✔
49
      attrs.rel = null;
2✔
50
    }
2✔
51
  }
4✔
52

7✔
53
  return htmlTag(tag, attrs, decode ? decodeURI(text) : text, false);
7!
54
};
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