@hashicorp/react-components 0.0.0-canary.b64fd2e → 0.0.0-canary.d3cafe1

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.b64fd2e",
3
+ "version": "0.0.0-canary.d3cafe1",
4
4
  "main": "src/index.ts",
5
5
  "scripts": {
6
6
  "lint": "next-hashicorp lint",
@@ -1,27 +1,27 @@
1
1
  import { parseUrl } from '.'
2
2
 
3
3
  describe('parseUrl', () => {
4
- it('handles internal urls', () => {
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('handles external urls', () => {
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('handles relative urls', () => {
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('handles search params', () => {
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
  } {
@@ -27,5 +27,4 @@ const isRelative = (url) => url.startsWith('/')
27
27
  const isAnchor = (url) => url.startsWith('#')
28
28
 
29
29
  export const isInternal = (url) =>
30
- url.startsWith('https://hashicorp.com') ||
31
- url.startsWith('https://www.hashicorp.com')
30
+ new URL(url).hostname.includes('hashicorp.com')
@@ -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<T extends string>(s: T): T {
8
- return vercelStegaSplit(s).cleaned as T
7
+ export function v<VercelVEString extends string>(
8
+ s: VercelVEString
9
+ ): VercelVEString {
10
+ return vercelStegaSplit(s).cleaned as VercelVEString
9
11
  }