mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 20:35:24 +00:00
Fix issue with share links not including domain sub paths
This commit is contained in:
parent
af8559678c
commit
11c79d850f
2 changed files with 7 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
import { NEXT_PUBLIC_DOMAIN_SUB_PATH } from "@/lib/environment.client";
|
||||
import { fileSourceResponseSchema, listRepositoriesResponseSchema, searchResponseSchema } from "@/lib/schemas";
|
||||
import { FileSourceRequest, FileSourceResponse, ListRepositoriesResponse, SearchRequest, SearchResponse } from "@/lib/types";
|
||||
import assert from "assert";
|
||||
|
||||
export const search = async (body: SearchRequest): Promise<SearchResponse> => {
|
||||
const path = resolveServerPath("/api/search");
|
||||
|
|
@ -48,5 +49,6 @@ export const getRepos = async (): Promise<ListRepositoriesResponse> => {
|
|||
* the base path (if any).
|
||||
*/
|
||||
export const resolveServerPath = (path: string) => {
|
||||
assert(path.startsWith("/"));
|
||||
return `${NEXT_PUBLIC_DOMAIN_SUB_PATH}${path}`;
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import { autoPlacement, computePosition, offset, shift, VirtualElement } from "@
|
|||
import { Link2Icon } from "@radix-ui/react-icons";
|
||||
import { EditorView, SelectionRange } from "@uiw/react-codemirror";
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
import { resolveServerPath } from "../api/(client)/client";
|
||||
|
||||
interface ContextMenuProps {
|
||||
view: EditorView;
|
||||
|
|
@ -103,7 +104,10 @@ export const EditorContextMenu = ({
|
|||
const from = toLineAndColumn(selection.from);
|
||||
const to = toLineAndColumn(selection.to);
|
||||
|
||||
const url = createPathWithQueryParams(`${window.location.origin}/browse/${repoName}@${revisionName}/-/blob/${path}`,
|
||||
// @note: we need to resolve the server path for /browse since
|
||||
// we aren't using <Link /> (which normally does this for us).
|
||||
const basePath = `${window.location.origin}${resolveServerPath('/browse')}`;
|
||||
const url = createPathWithQueryParams(`${basePath}/${repoName}@${revisionName}/-/blob/${path}`,
|
||||
['highlightRange', `${from?.line}:${from?.column},${to?.line}:${to?.column}`],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue