@pequity/squirrel 4.1.0 → 4.1.2
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/dist/cjs/link.js +1 -5
- package/dist/es/link.js +1 -5
- package/package.json +5 -5
- package/squirrel/utils/link.spec.js +26 -12
- package/squirrel/utils/link.ts +1 -14
package/dist/cjs/link.js
CHANGED
|
@@ -14,12 +14,8 @@ const isValidUrl = (url) => {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
const checkDomain = function(url) {
|
|
18
|
-
url = normalizeUrl(url);
|
|
19
|
-
return url.toLowerCase().replace(/([a-z])?:\/\//, "$1").split("/")[0];
|
|
20
|
-
};
|
|
21
17
|
const isExternalLink = function(url) {
|
|
22
18
|
url = String(url);
|
|
23
|
-
return isValidUrl(url) && (url.indexOf(":") > -1 || url.indexOf("//") > -1)
|
|
19
|
+
return isValidUrl(url) && (url.indexOf(":") > -1 || url.indexOf("//") > -1);
|
|
24
20
|
};
|
|
25
21
|
exports.isExternalLink = isExternalLink;
|
package/dist/es/link.js
CHANGED
|
@@ -12,13 +12,9 @@ const isValidUrl = (url) => {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const checkDomain = function(url) {
|
|
16
|
-
url = normalizeUrl(url);
|
|
17
|
-
return url.toLowerCase().replace(/([a-z])?:\/\//, "$1").split("/")[0];
|
|
18
|
-
};
|
|
19
15
|
const isExternalLink = function(url) {
|
|
20
16
|
url = String(url);
|
|
21
|
-
return isValidUrl(url) && (url.indexOf(":") > -1 || url.indexOf("//") > -1)
|
|
17
|
+
return isValidUrl(url) && (url.indexOf(":") > -1 || url.indexOf("//") > -1);
|
|
22
18
|
};
|
|
23
19
|
export {
|
|
24
20
|
isExternalLink
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pequity/squirrel",
|
|
3
3
|
"description": "Squirrel component library",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"packageManager": "pnpm@9.7.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/core": "^7.25.2",
|
|
54
54
|
"@babel/preset-env": "^7.25.4",
|
|
55
|
-
"@commitlint/cli": "^19.4.
|
|
56
|
-
"@commitlint/config-conventional": "^19.
|
|
55
|
+
"@commitlint/cli": "^19.4.1",
|
|
56
|
+
"@commitlint/config-conventional": "^19.4.1",
|
|
57
57
|
"@pequity/eslint-config": "^0.0.13",
|
|
58
58
|
"@playwright/test": "^1.46.1",
|
|
59
59
|
"@popperjs/core": "2.11.8",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"@storybook/theming": "^8.2.9",
|
|
72
72
|
"@storybook/vue3": "^8.2.9",
|
|
73
73
|
"@storybook/vue3-vite": "^8.2.9",
|
|
74
|
-
"@tanstack/vue-virtual": "3.10.
|
|
74
|
+
"@tanstack/vue-virtual": "3.10.5",
|
|
75
75
|
"@types/jest": "^29.5.12",
|
|
76
76
|
"@types/jsdom": "^21.1.7",
|
|
77
77
|
"@types/lodash-es": "^4.17.12",
|
|
78
|
-
"@types/node": "^22.5.
|
|
78
|
+
"@types/node": "^22.5.1",
|
|
79
79
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
80
80
|
"@vue/compiler-sfc": "3.4.38",
|
|
81
81
|
"@vue/test-utils": "^2.4.6",
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { isExternalLink } from '@squirrel/utils/link';
|
|
2
2
|
|
|
3
3
|
describe('isExternalLink', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
delete window.location;
|
|
6
|
+
|
|
7
|
+
window.location = new URL('https://www.example.com');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it.each([
|
|
11
|
+
'https://www.example.com',
|
|
12
|
+
'http://www.example.com',
|
|
13
|
+
'//www.example.com',
|
|
14
|
+
'https://www.pequity.com',
|
|
15
|
+
'http://www.pequity.com',
|
|
16
|
+
'//www.pequity.com',
|
|
17
|
+
])('should return true for external links (%s)', (val) => {
|
|
18
|
+
expect(isExternalLink(val)).toBe(true);
|
|
19
|
+
});
|
|
10
20
|
|
|
11
21
|
it.each(['/home', 'home', '#home', '/home//1/', '/home:1/', '#home:', { name: 'home' }])(
|
|
12
22
|
'should return false for internal links (%s)',
|
|
@@ -15,10 +25,14 @@ describe('isExternalLink', () => {
|
|
|
15
25
|
}
|
|
16
26
|
);
|
|
17
27
|
|
|
18
|
-
it.each([
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
it.each([
|
|
29
|
+
'ftp://www.example.com',
|
|
30
|
+
'mailto:test@example.com',
|
|
31
|
+
'ftp://www.pequity.com',
|
|
32
|
+
'mailto:test@pequity.com',
|
|
33
|
+
'tel:+1234567890',
|
|
34
|
+
'sms:+1234567890',
|
|
35
|
+
])('should handle different protocols (%s)', (val) => {
|
|
36
|
+
expect(isExternalLink(val)).toBe(true);
|
|
37
|
+
});
|
|
24
38
|
});
|
package/squirrel/utils/link.ts
CHANGED
|
@@ -16,21 +16,8 @@ const isValidUrl = (url: string) => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const checkDomain = function (url: string) {
|
|
20
|
-
url = normalizeUrl(url);
|
|
21
|
-
|
|
22
|
-
return url
|
|
23
|
-
.toLowerCase()
|
|
24
|
-
.replace(/([a-z])?:\/\//, '$1')
|
|
25
|
-
.split('/')[0];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
19
|
export const isExternalLink = function (url: string) {
|
|
29
20
|
url = String(url);
|
|
30
21
|
|
|
31
|
-
return (
|
|
32
|
-
isValidUrl(url) &&
|
|
33
|
-
(url.indexOf(':') > -1 || url.indexOf('//') > -1) &&
|
|
34
|
-
checkDomain(location.href) !== checkDomain(url)
|
|
35
|
-
);
|
|
22
|
+
return isValidUrl(url) && (url.indexOf(':') > -1 || url.indexOf('//') > -1);
|
|
36
23
|
};
|