@gravity-ui/page-constructor 1.16.3 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.js +63 -0
- package/build/cjs/components/OverflowScroller/OverflowScroller.css +16 -5
- package/build/cjs/components/OverflowScroller/OverflowScroller.d.ts +1 -1
- package/build/cjs/components/OverflowScroller/OverflowScroller.js +13 -5
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +1 -0
- package/build/cjs/models/navigation.d.ts +9 -3
- package/build/cjs/models/navigation.js +1 -0
- package/build/cjs/navigation/components/Header/Header.css +2 -2
- package/build/cjs/navigation/components/Header/Header.js +1 -1
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.css +0 -35
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +9 -39
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.css +7 -0
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js +12 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +10 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +5 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +11 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.css +3 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +15 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.css +4 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +19 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.css +21 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +30 -0
- package/build/cjs/sub-blocks/BasicCard/BasicCard.js +2 -2
- package/build/cjs/sub-blocks/BasicCard/schema.d.ts +4 -0
- package/build/cjs/sub-blocks/BasicCard/schema.js +4 -1
- package/build/cjs/utils/url.d.ts +1 -0
- package/build/cjs/utils/url.js +13 -10
- package/build/cjs/utils/url.test.d.ts +1 -0
- package/build/cjs/utils/url.test.js +76 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.js +60 -0
- package/build/esm/components/OverflowScroller/OverflowScroller.css +16 -5
- package/build/esm/components/OverflowScroller/OverflowScroller.d.ts +1 -1
- package/build/esm/components/OverflowScroller/OverflowScroller.js +13 -5
- package/build/esm/models/constructor-items/sub-blocks.d.ts +1 -0
- package/build/esm/models/navigation.d.ts +9 -3
- package/build/esm/models/navigation.js +1 -0
- package/build/esm/navigation/components/Header/Header.css +2 -2
- package/build/esm/navigation/components/Header/Header.js +1 -1
- package/build/esm/navigation/components/NavigationItem/NavigationItem.css +0 -35
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +9 -39
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.css +7 -0
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js +8 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +10 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +6 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.css +3 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +11 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.css +4 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +16 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.css +21 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +27 -0
- package/build/esm/sub-blocks/BasicCard/BasicCard.js +3 -2
- package/build/esm/sub-blocks/BasicCard/schema.d.ts +4 -0
- package/build/esm/sub-blocks/BasicCard/schema.js +4 -1
- package/build/esm/utils/url.d.ts +1 -0
- package/build/esm/utils/url.js +11 -9
- package/build/esm/utils/url.test.d.ts +1 -0
- package/build/esm/utils/url.test.js +74 -0
- package/package.json +2 -1
- package/server/models/constructor-items/sub-blocks.d.ts +1 -0
- package/server/models/navigation.d.ts +9 -3
- package/server/models/navigation.js +1 -0
- package/server/utils/url.d.ts +1 -0
- package/server/utils/url.js +13 -10
package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { Fragment, useContext } from 'react';
|
|
3
|
+
import { ContentWrapper } from '../ContentWrapper/ContentWrapper';
|
|
4
|
+
import { NavigationArrow } from '../../../../../icons';
|
|
5
|
+
import { RouterLink } from '../../../../../components';
|
|
6
|
+
import { block, getLinkProps } from '../../../../../utils';
|
|
7
|
+
import { getMediaImage } from '../../../../../components/Media/Image/utils';
|
|
8
|
+
import { LocationContext } from '../../../../../context/locationContext';
|
|
9
|
+
import './NavigationLink.css';
|
|
10
|
+
const b = block('navigation-link');
|
|
11
|
+
export const NavigationLink = (props) => {
|
|
12
|
+
const { hostname, Link } = useContext(LocationContext);
|
|
13
|
+
const { url, text, icon, arrow, target, className } = props, rest = __rest(props, ["url", "text", "icon", "arrow", "target", "className"]);
|
|
14
|
+
const linkExtraProps = getLinkProps(url, hostname, target);
|
|
15
|
+
const iconData = icon && getMediaImage(icon);
|
|
16
|
+
const classes = b(null, className);
|
|
17
|
+
const content = (React.createElement(Fragment, null,
|
|
18
|
+
React.createElement(ContentWrapper, { text: text, icon: iconData }),
|
|
19
|
+
arrow && React.createElement(NavigationArrow, { className: b('arrow') })));
|
|
20
|
+
if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
|
|
21
|
+
return (React.createElement("a", Object.assign({ href: url, title: text, className: classes }, rest, linkExtraProps), content));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return (React.createElement(RouterLink, { href: url, passHref: true },
|
|
25
|
+
React.createElement("a", Object.assign({}, rest, { className: classes }), content)));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { block } from '../../utils';
|
|
3
4
|
import CardBase from '../../components/CardBase/CardBase';
|
|
@@ -7,9 +8,9 @@ import { getMediaImage } from '../../components/Media/Image/utils';
|
|
|
7
8
|
import './BasicCard.css';
|
|
8
9
|
const b = block('basic-card');
|
|
9
10
|
const BasicCard = (props) => {
|
|
10
|
-
const {
|
|
11
|
+
const { title, text, icon, additionalInfo, links, buttons } = props, cardParams = __rest(props, ["title", "text", "icon", "additionalInfo", "links", "buttons"]);
|
|
11
12
|
const iconProps = icon && getMediaImage(icon);
|
|
12
|
-
return (React.createElement(CardBase, { className: b()
|
|
13
|
+
return (React.createElement(CardBase, Object.assign({ className: b() }, cardParams),
|
|
13
14
|
React.createElement(CardBase.Content, null,
|
|
14
15
|
iconProps && React.createElement(Image, Object.assign({}, iconProps, { className: b('icon') })),
|
|
15
16
|
React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 }, size: "s" }))));
|
|
@@ -9,6 +9,9 @@ export const BasicCard = {
|
|
|
9
9
|
required: ['url'],
|
|
10
10
|
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, BaseProps), CardBase), BasicCardContentProps), { url: {
|
|
11
11
|
type: 'string',
|
|
12
|
-
}, icon: ImageProps
|
|
12
|
+
}, icon: ImageProps, target: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
enum: ['_blank', '_parent', '_top', '_self'],
|
|
15
|
+
} }),
|
|
13
16
|
},
|
|
14
17
|
};
|
package/build/esm/utils/url.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const EXTERNAL_LINK_PROPS: {
|
|
|
6
6
|
export declare function getLinkProps(url: string, hostname?: string, target?: string): {
|
|
7
7
|
target: string | undefined;
|
|
8
8
|
};
|
|
9
|
+
export declare function isAbsoluteUrl(url: string | URL): boolean;
|
|
9
10
|
export declare function isLinkExternal(url: string, routerHostname?: string): boolean;
|
|
10
11
|
export declare function getNonLocaleHostName(hostname: string): string;
|
|
11
12
|
export declare function setUrlTld(url: string, tld?: string): string;
|
package/build/esm/utils/url.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { parse, format } from 'url';
|
|
2
|
+
const EXAMPLE_URL = 'https://example.org';
|
|
2
3
|
export const EXTERNAL_LINK_PROPS = { target: '_blank', rel: 'noopener noreferrer' };
|
|
3
4
|
export function getLinkProps(url, hostname, target) {
|
|
4
5
|
let linkProps = { target };
|
|
5
|
-
if (
|
|
6
|
+
if (isLinkExternal(url, hostname)) {
|
|
6
7
|
linkProps = Object.assign(Object.assign({}, linkProps), EXTERNAL_LINK_PROPS);
|
|
7
8
|
}
|
|
8
9
|
return linkProps;
|
|
9
10
|
}
|
|
11
|
+
export function isAbsoluteUrl(url) {
|
|
12
|
+
// Using example URL as base for relative links
|
|
13
|
+
const urlObj = new URL(url, EXAMPLE_URL);
|
|
14
|
+
return (
|
|
15
|
+
// Compare url origin with example and check that original url was not example one
|
|
16
|
+
urlObj.origin !== EXAMPLE_URL || (typeof url === 'string' && url.startsWith(EXAMPLE_URL)));
|
|
17
|
+
}
|
|
10
18
|
export function isLinkExternal(url, routerHostname) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const { hostname } = parse(url);
|
|
15
|
-
if (!hostname) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return getNonLocaleHostName(hostname) !== getNonLocaleHostName(routerHostname);
|
|
19
|
+
return (isAbsoluteUrl(url) &&
|
|
20
|
+
getNonLocaleHostName(new URL(url).hostname) !== getNonLocaleHostName(routerHostname !== null && routerHostname !== void 0 ? routerHostname : ''));
|
|
19
21
|
}
|
|
20
22
|
export function getNonLocaleHostName(hostname) {
|
|
21
23
|
return hostname.replace(/\.(ru|com)$/, '');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getLinkProps, isAbsoluteUrl, isLinkExternal } from './url';
|
|
2
|
+
describe('URL utils check', () => {
|
|
3
|
+
test.each([
|
|
4
|
+
['https://user:pass@sub.example.com:8080/p/a/t/h?query=string&query2=1#hash', true],
|
|
5
|
+
['http://example.net/path', true],
|
|
6
|
+
['/p/a/t/h?query=string&query2=1#hash', false],
|
|
7
|
+
['/path', false],
|
|
8
|
+
['path', false],
|
|
9
|
+
])("isAbsoluteUrl('%s') should return '%s'", (url, result) => {
|
|
10
|
+
expect(isAbsoluteUrl(url)).toEqual(result);
|
|
11
|
+
});
|
|
12
|
+
test.each([
|
|
13
|
+
[
|
|
14
|
+
'https://user:pass@sub.example.com:8080/p/a/t/h?query=string&query2=1#hash',
|
|
15
|
+
'example.net',
|
|
16
|
+
true,
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
'https://user:pass@sub.example.com:8080/p/a/t/h?query=string&query2=1#hash',
|
|
20
|
+
'sub.example.com',
|
|
21
|
+
false,
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
'https://user:pass@sub.example.com:8080/p/a/t/h?query=string&query2=1#hash',
|
|
25
|
+
undefined,
|
|
26
|
+
true,
|
|
27
|
+
],
|
|
28
|
+
['http://example.net/path', 'example.net', false],
|
|
29
|
+
['http://example.net/path', 'sub.example.com', true],
|
|
30
|
+
['http://example.net/path', undefined, true],
|
|
31
|
+
['/p/a/t/h?query=string&query2=1#hash', 'example.net', false],
|
|
32
|
+
['/p/a/t/h?query=string&query2=1#hash', undefined, false],
|
|
33
|
+
['/path', 'example.net', false],
|
|
34
|
+
['/path', undefined, false],
|
|
35
|
+
['path', 'example.net', false],
|
|
36
|
+
['path', undefined, false],
|
|
37
|
+
])("isLinkExternal('%s', '%s') should return '%s'", (url, hostname, result) => {
|
|
38
|
+
expect(isLinkExternal(url, hostname)).toEqual(result);
|
|
39
|
+
});
|
|
40
|
+
test.each([
|
|
41
|
+
['http://example.net/path', 'example.net', '_blank', { target: '_blank' }],
|
|
42
|
+
['http://example.net/path', 'example.net', undefined, {}],
|
|
43
|
+
[
|
|
44
|
+
'http://example.net/path',
|
|
45
|
+
'example.com',
|
|
46
|
+
'_blank',
|
|
47
|
+
{ target: '_blank', rel: 'noopener noreferrer' },
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
'http://example.net/path',
|
|
51
|
+
'example.com',
|
|
52
|
+
undefined,
|
|
53
|
+
{ target: '_blank', rel: 'noopener noreferrer' },
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
'http://example.net/path',
|
|
57
|
+
undefined,
|
|
58
|
+
'_blank',
|
|
59
|
+
{ target: '_blank', rel: 'noopener noreferrer' },
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
'http://example.net/path',
|
|
63
|
+
undefined,
|
|
64
|
+
undefined,
|
|
65
|
+
{ target: '_blank', rel: 'noopener noreferrer' },
|
|
66
|
+
],
|
|
67
|
+
['/path', 'example.net', '_blank', { target: '_blank' }],
|
|
68
|
+
['/path', 'example.net', undefined, {}],
|
|
69
|
+
['/path', undefined, '_blank', { target: '_blank' }],
|
|
70
|
+
['/path', undefined, undefined, {}],
|
|
71
|
+
])("getLinkProps('%s', '%s', '%s') should return '%s'", (url, hostname, target, result) => {
|
|
72
|
+
expect(getLinkProps(url, hostname, target)).toEqual(result);
|
|
73
|
+
});
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/page-constructor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@gravity-ui/i18n": "^1.0.0",
|
|
50
50
|
"bem-cn-lite": "^4.0.0",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
|
+
"react-github-btn": "^1.4.0",
|
|
52
53
|
"react-player": "^2.9.0",
|
|
53
54
|
"react-slick": "^0.28.1",
|
|
54
55
|
"react-spring": "^9.3.0",
|
|
@@ -106,6 +106,7 @@ export interface BackgroundCardProps extends CardBaseProps, Omit<ContentBlockPro
|
|
|
106
106
|
export interface BasicCardProps extends CardBaseProps, Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
|
|
107
107
|
url: string;
|
|
108
108
|
icon?: ImageProps;
|
|
109
|
+
target?: string;
|
|
109
110
|
}
|
|
110
111
|
export interface BannerCardProps {
|
|
111
112
|
title: string;
|
|
@@ -4,13 +4,19 @@ export declare enum NavigationItemType {
|
|
|
4
4
|
Link = "link",
|
|
5
5
|
Dropdown = "dropdown",
|
|
6
6
|
Button = "button",
|
|
7
|
-
Social = "social"
|
|
7
|
+
Social = "social",
|
|
8
|
+
GithubStars = "github-stars"
|
|
8
9
|
}
|
|
9
10
|
export interface NavigationItemBase {
|
|
10
11
|
text: string;
|
|
11
12
|
icon?: ImageProps;
|
|
12
13
|
url?: string;
|
|
13
14
|
}
|
|
15
|
+
export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
|
|
16
|
+
type: NavigationItemType.GithubStars;
|
|
17
|
+
url: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
14
20
|
export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
|
|
15
21
|
type: NavigationItemType.Link;
|
|
16
22
|
url: string;
|
|
@@ -29,8 +35,8 @@ export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
|
|
|
29
35
|
icon: ImageProps;
|
|
30
36
|
url: string;
|
|
31
37
|
}
|
|
32
|
-
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem;
|
|
33
|
-
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
|
|
38
|
+
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem | NavigationGithubButton;
|
|
39
|
+
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData | NavigationGithubButton;
|
|
34
40
|
export type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
|
|
35
41
|
export interface NavigationLogoData {
|
|
36
42
|
icon: ImageProps;
|
|
@@ -7,4 +7,5 @@ var NavigationItemType;
|
|
|
7
7
|
NavigationItemType["Dropdown"] = "dropdown";
|
|
8
8
|
NavigationItemType["Button"] = "button";
|
|
9
9
|
NavigationItemType["Social"] = "social";
|
|
10
|
+
NavigationItemType["GithubStars"] = "github-stars";
|
|
10
11
|
})(NavigationItemType = exports.NavigationItemType || (exports.NavigationItemType = {}));
|
package/server/utils/url.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const EXTERNAL_LINK_PROPS: {
|
|
|
6
6
|
export declare function getLinkProps(url: string, hostname?: string, target?: string): {
|
|
7
7
|
target: string | undefined;
|
|
8
8
|
};
|
|
9
|
+
export declare function isAbsoluteUrl(url: string | URL): boolean;
|
|
9
10
|
export declare function isLinkExternal(url: string, routerHostname?: string): boolean;
|
|
10
11
|
export declare function getNonLocaleHostName(hostname: string): string;
|
|
11
12
|
export declare function setUrlTld(url: string, tld?: string): string;
|
package/server/utils/url.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAbsolutePath = exports.getPageSearchParams = exports.setUrlTld = exports.getNonLocaleHostName = exports.isLinkExternal = exports.getLinkProps = exports.EXTERNAL_LINK_PROPS = void 0;
|
|
3
|
+
exports.getAbsolutePath = exports.getPageSearchParams = exports.setUrlTld = exports.getNonLocaleHostName = exports.isLinkExternal = exports.isAbsoluteUrl = exports.getLinkProps = exports.EXTERNAL_LINK_PROPS = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
|
+
const EXAMPLE_URL = 'https://example.org';
|
|
5
6
|
exports.EXTERNAL_LINK_PROPS = { target: '_blank', rel: 'noopener noreferrer' };
|
|
6
7
|
function getLinkProps(url, hostname, target) {
|
|
7
8
|
let linkProps = { target };
|
|
8
|
-
if (
|
|
9
|
+
if (isLinkExternal(url, hostname)) {
|
|
9
10
|
linkProps = Object.assign(Object.assign({}, linkProps), exports.EXTERNAL_LINK_PROPS);
|
|
10
11
|
}
|
|
11
12
|
return linkProps;
|
|
12
13
|
}
|
|
13
14
|
exports.getLinkProps = getLinkProps;
|
|
15
|
+
function isAbsoluteUrl(url) {
|
|
16
|
+
// Using example URL as base for relative links
|
|
17
|
+
const urlObj = new URL(url, EXAMPLE_URL);
|
|
18
|
+
return (
|
|
19
|
+
// Compare url origin with example and check that original url was not example one
|
|
20
|
+
urlObj.origin !== EXAMPLE_URL || (typeof url === 'string' && url.startsWith(EXAMPLE_URL)));
|
|
21
|
+
}
|
|
22
|
+
exports.isAbsoluteUrl = isAbsoluteUrl;
|
|
14
23
|
function isLinkExternal(url, routerHostname) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const { hostname } = (0, url_1.parse)(url);
|
|
19
|
-
if (!hostname) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return getNonLocaleHostName(hostname) !== getNonLocaleHostName(routerHostname);
|
|
24
|
+
return (isAbsoluteUrl(url) &&
|
|
25
|
+
getNonLocaleHostName(new URL(url).hostname) !== getNonLocaleHostName(routerHostname !== null && routerHostname !== void 0 ? routerHostname : ''));
|
|
23
26
|
}
|
|
24
27
|
exports.isLinkExternal = isLinkExternal;
|
|
25
28
|
function getNonLocaleHostName(hostname) {
|