Skip to content

Commit

Permalink
fix: fix matcher of search article via url
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed May 24, 2024
1 parent b19ce7d commit cfc9ddb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,13 @@ const EditorSearchingArea: React.FC<SearchingAreaProps> = ({
// Used to match links of the format like👇
// https://matters.town/a/{shortHash}
const regex = new RegExp(
`^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+$`
`^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+`
)
if (searchType === 'Article' && isUrl(key) && regex.test(key)) {
const urlObj = parseURL(key)
const shortHash = urlObj.pathname.split('/a/')[1].split('?')[0]
setMode('article_url')
lazyArticleUrlQuery({
variables: { shortHash },
})
lazyArticleUrlQuery({ variables: { shortHash } })
} else {
const type = searchType
lazySearch({
Expand Down
6 changes: 2 additions & 4 deletions src/components/SearchSelect/SearchingArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@ const SearchingArea: React.FC<SearchingAreaProps> = ({
// Used to match links of the format like👇
// https://matters.town/a/{shortHash}
const regex = new RegExp(
`^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+$`
`^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+`
)
if (searchType === 'Article' && isUrl(key) && regex.test(key)) {
const urlObj = parseURL(key)
const shortHash = urlObj.pathname.split('/a/')[1].split('?')[0]
setMode('article_url')
lazyArticleUrlQuery({
variables: { shortHash },
})
lazyArticleUrlQuery({ variables: { shortHash } })
} else {
const type = searchType === 'Invitee' ? 'User' : searchType
lazySearch({
Expand Down

0 comments on commit cfc9ddb

Please sign in to comment.