Skip to content

Commit

Permalink
fix: incorrect href if search result contains #... (close AlistGo/a…
Browse files Browse the repository at this point in the history
…list#2907 #43)

* fix: 修复搜索结果包含特殊符号跳转失败的BUG

* fix: 修复搜索结果包含特殊符号跳转失败的BUG

* do not change path

Co-authored-by: zxdstyle <[email protected]>
Co-authored-by: Noah Hsu <[email protected]>
  • Loading branch information
3 people authored Jan 5, 2023
1 parent 92e8fb0 commit ca8c7a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/components/LinkWithBase.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { Link, LinkProps } from "@solidjs/router"
import { Link } from "@solidjs/router"
import { Anchor, AnchorProps, ElementType } from "@hope-ui/solid"
import { joinBase } from "~/utils"
import { joinBase, encodePath } from "~/utils"
import { useRouter } from "~/hooks"
export const LinkWithBase = (props: LinkProps) => (
<Link {...props} href={joinBase(props.href)} />
import { ComponentProps } from "solid-js"

export const LinkWithBase = (
props: ComponentProps<typeof Link> & { encode?: boolean }
) => (
<Link
{...props}
href={joinBase(props.encode ? encodePath(props.href) : props.href)}
/>
)

export const AnchorWithBase = <C extends ElementType = "a">(
props: AnchorProps<C>
) => <Anchor {...props} href={joinBase(props.href)} />

export const LinkWithPush = (props: LinkProps) => {
export const LinkWithPush = (props: ComponentProps<typeof LinkWithBase>) => {
const { pushHref } = useRouter()
return <LinkWithBase {...props} href={pushHref(props.href)} />
}
1 change: 1 addition & 0 deletions src/pages/home/folder/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const SearchResult = (props: SearchNode) => {
px="$2"
as={LinkWithBase}
href={props.path}
encode
>
<Icon
class="icon"
Expand Down

0 comments on commit ca8c7a3

Please sign in to comment.