@hashicorp/react-components 0.0.0-canary.866e055 → 0.0.0-canary.a52cc0f
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/react-components",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.a52cc0f",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "next-hashicorp lint",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"@hashicorp/platform-util": "^0.2.0",
|
|
14
14
|
"@hashicorp/react-design-system-components": "*",
|
|
15
15
|
"@hashicorp/web-mktg-logos": "*",
|
|
16
|
-
"@radix-ui/react-
|
|
16
|
+
"@radix-ui/react-navigation-menu": "^1.2.0",
|
|
17
|
+
"@radix-ui/react-visually-hidden": "^1.1.0",
|
|
17
18
|
"@vercel/analytics": "^1.3.1",
|
|
18
19
|
"@vercel/fetch": "^7.0.0",
|
|
19
20
|
"@vercel/stega": "^0.1.2",
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { parseUrl } from '.'
|
|
2
2
|
|
|
3
3
|
describe('parseUrl', () => {
|
|
4
|
-
it('
|
|
4
|
+
it('detects hashicorp.com URLs as internal', () => {
|
|
5
5
|
const url = parseUrl('https://hashicorp.com/example')
|
|
6
6
|
expect(url.href).toBe('/example')
|
|
7
7
|
expect(url.linkType).toBe('inbound')
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
-
it('
|
|
10
|
+
it('detects URLs not containing hashicorp.com as external', () => {
|
|
11
11
|
const externalUrl = 'https://google.com/example'
|
|
12
12
|
const url = parseUrl(externalUrl)
|
|
13
13
|
expect(url.href).toBe(externalUrl)
|
|
14
14
|
expect(url.linkType).toBe('outbound')
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
it('
|
|
17
|
+
it('detects relative URLs as internal', () => {
|
|
18
18
|
const relativeUrl = '/resources'
|
|
19
19
|
const url = parseUrl(relativeUrl)
|
|
20
20
|
expect(url.href).toBe(relativeUrl)
|
|
21
21
|
expect(url.linkType).toBe('inbound')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
it('
|
|
24
|
+
it('leaves URL search params intact', () => {
|
|
25
25
|
const url = parseUrl(
|
|
26
26
|
'https://hashicorp.com/resources?type=case-study&products=terraform'
|
|
27
27
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function parseUrl(url: string): {
|
|
1
|
+
export function parseUrl(url: string | undefined): {
|
|
2
2
|
linkType: 'inbound' | 'outbound'
|
|
3
3
|
href: string
|
|
4
4
|
} {
|
|
@@ -26,6 +26,4 @@ export function parseUrl(url: string): {
|
|
|
26
26
|
const isRelative = (url) => url.startsWith('/')
|
|
27
27
|
const isAnchor = (url) => url.startsWith('#')
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
url.startsWith('https://hashicorp.com') ||
|
|
31
|
-
url.startsWith('https://www.hashicorp.com')
|
|
29
|
+
const isInternal = (url) => new URL(url).hostname.includes('hashicorp.com')
|
package/src/lib/v/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { vercelStegaSplit } from '@vercel/stega'
|
|
|
4
4
|
* Takes in a Vercel Visual Editing string and returns the string without
|
|
5
5
|
* hidden data.
|
|
6
6
|
*/
|
|
7
|
-
export function v<
|
|
8
|
-
|
|
7
|
+
export function v<VercelVEString extends string>(
|
|
8
|
+
s: VercelVEString
|
|
9
|
+
): VercelVEString {
|
|
10
|
+
return vercelStegaSplit(s).cleaned as VercelVEString
|
|
9
11
|
}
|