Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
YuHyun-P committed Aug 16, 2022
2 parents 7093e06 + 3072bf0 commit d997024
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion pages/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Create = () => {

const handleCreate = () => {
setSubmit(true);
if (url === "") {
if (url === "" || url.endsWith("/") || result) {
urlRef.current?.focus();
} else if (title === "") {
titleRef.current?.focus();
Expand Down Expand Up @@ -87,6 +87,10 @@ const Create = () => {
}
}

if (url.endsWith("/")) {
return;
}

const response = await bookmarkAPI.getLinkMetadata(url);
if (response.data.title.length > 47) {
setTitle(`${response.data.title.substring(0, 47)}...`);
Expand Down Expand Up @@ -158,6 +162,11 @@ const Create = () => {
{result && (
<ErrorText>* 중복된 url은 등록할 수 없습니다.</ErrorText>
)}
{url.endsWith("/") && (
<ErrorText>
* 현재 url에서 마지막 &#39;/&#39;를 제거해주세요.
</ErrorText>
)}
<div style={{ marginBottom: "40px" }} />

<StyledLabel>
Expand Down
6 changes: 4 additions & 2 deletions utils/apis/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ const bookmarkAPI = {
),
getFeedBookmarks: (queryString: string) =>
authInstance.get<BookmarkList>(`/bookmarks/feed?${queryString}`),
getLinkMetadata: (link: string) =>
authInstance.post<{ title: string }>(`/linkmetadatas/obtain?link=${link}`),
getLinkMetadata: (url: string) =>
authInstance.post<{ title: string }>(`/linkmetadatas/obtain`, {
url,
}),
getIsDuplicateUrl: (url: string) =>
authInstance.get<{ isDuplicateUrl: boolean }>(`/bookmarks?url=${url}`),
createFavorite: (bookmarkId: string) =>
Expand Down

1 comment on commit d997024

@vercel
Copy link

@vercel vercel bot commented on d997024 Aug 16, 2022

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.