Skip to content

Commit

Permalink
fix: get link if base path isn't root folder
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 10, 2022
1 parent d8ba1d6 commit a37dc59
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/hooks/useLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { objStore, selectedObjs, State } from "~/store";
import { objStore, selectedObjs, State, user } from "~/store";
import { Obj } from "~/types";
import { api, base_path, encodePath, pathDir, standardizePath } from "~/utils";
import {
api,
base_path,
encodePath,
pathDir,
pathJoin,
standardizePath,
} from "~/utils";
import { useRouter, useUtil } from ".";

type URLType = "preview" | "direct" | "proxy";
Expand All @@ -12,7 +19,7 @@ export const getLinkByDirAndObj = (
type: URLType = "direct",
encodeAll?: boolean
) => {
dir = standardizePath(dir, true);
dir = standardizePath(pathJoin(user().base_path, dir), true);
let path = `${dir}/${obj.name}`;
path = encodePath(path, encodeAll);
let host = api;
Expand Down

0 comments on commit a37dc59

Please sign in to comment.