Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fix removing links after post update
Browse files Browse the repository at this point in the history
  • Loading branch information
wceolin committed Jun 18, 2020
1 parent ca1252d commit 7985276
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/components/rich-text/__tests__/posts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('getPostLinks', () => {
{ text: 'An opening paragraph with a ' },
{
type: 'link',
href: 'https://zoonk.org',
url: 'https://zoonk.org',
children: [{ text: 'link' }],
},
{ text: ' in it.' },
Expand All @@ -116,7 +116,7 @@ describe('getPostLinks', () => {
{ text: 'A nested item with a ' },
{
type: 'link',
href: '/test',
url: '/test',
children: [{ text: 'link' }],
},
{ text: ' in it.' },
Expand All @@ -130,7 +130,7 @@ describe('getPostLinks', () => {
{ text: 'Now we have the same ' },
{
type: 'link',
href: 'https://zoonk.org',
url: 'https://zoonk.org',
children: [{ text: 'link' }],
},
{ text: ', which should be deleted.' },
Expand Down
4 changes: 2 additions & 2 deletions src/components/rich-text/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const getLinks = (node: Node): string[] => {

const children = node.children
.map((n) => {
if (n.href) {
const link = n.href as string;
if (n.url) {
const link = n.url as string;
return link.startsWith('/') ? `${rootUrl}${link}` : link;
}
if (n.children) return getLinks(n);
Expand Down

1 comment on commit 7985276

@vercel
Copy link

@vercel vercel bot commented on 7985276 Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.