Skip to content

Commit

Permalink
fix: only convert for b23.tv url
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 12, 2023
1 parent 32fcb3e commit a89c348
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hooks/notes/flomo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { useAnalytics } from '~/components/context/analytics'
import { useAnalytics } from "~/components/context/analytics";
import { useToast } from "~/hooks/use-toast";

export function useSaveToFlomo(note: string, webhook: string) {
Expand All @@ -15,7 +15,7 @@ export function useSaveToFlomo(note: string, webhook: string) {
"Content-Type": "application/json",
},
body: JSON.stringify({
content: note + "#BibiGpt",
content: note + "\n#BibiGpt",
}),
});
const json = await response.json();
Expand Down
11 changes: 7 additions & 4 deletions pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ export const Home: NextPage<{

const handleInputChange = async (e: any) => {
const value = e.target.value;
// todo: 兼容?query参数
const regex = /((?:https?:\/\/|www\.)\S+)/g;
const matches = value.match(regex);
if (matches) {
const url = matches[0];
toast({ title: "正在自动转换此视频链接..." });
const response = await fetch(`/api/b23tv?url=${url}`);
const json = await response.json();
setCurrentVideoUrl(json.url);
if (url.includes("b23.tv")) {
toast({ title: "正在自动转换此视频链接..." });
const response = await fetch(`/api/b23tv?url=${url}`);
const json = await response.json();
setCurrentVideoUrl(json.url);
}
} else {
setCurrentVideoUrl(value);
}
Expand Down

1 comment on commit a89c348

@vercel
Copy link

@vercel vercel bot commented on a89c348 Mar 12, 2023

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.