mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 21:05:22 +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 { NEXT_PUBLIC_DOMAIN_SUB_PATH } from "@/lib/environment.client";
|
||||||
import { fileSourceResponseSchema, listRepositoriesResponseSchema, searchResponseSchema } from "@/lib/schemas";
|
import { fileSourceResponseSchema, listRepositoriesResponseSchema, searchResponseSchema } from "@/lib/schemas";
|
||||||
import { FileSourceRequest, FileSourceResponse, ListRepositoriesResponse, SearchRequest, SearchResponse } from "@/lib/types";
|
import { FileSourceRequest, FileSourceResponse, ListRepositoriesResponse, SearchRequest, SearchResponse } from "@/lib/types";
|
||||||
|
import assert from "assert";
|
||||||
|
|
||||||
export const search = async (body: SearchRequest): Promise<SearchResponse> => {
|
export const search = async (body: SearchRequest): Promise<SearchResponse> => {
|
||||||
const path = resolveServerPath("/api/search");
|
const path = resolveServerPath("/api/search");
|
||||||
|
|
@ -48,5 +49,6 @@ export const getRepos = async (): Promise<ListRepositoriesResponse> => {
|
||||||
* the base path (if any).
|
* the base path (if any).
|
||||||
*/
|
*/
|
||||||
export const resolveServerPath = (path: string) => {
|
export const resolveServerPath = (path: string) => {
|
||||||
|
assert(path.startsWith("/"));
|
||||||
return `${NEXT_PUBLIC_DOMAIN_SUB_PATH}${path}`;
|
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 { Link2Icon } from "@radix-ui/react-icons";
|
||||||
import { EditorView, SelectionRange } from "@uiw/react-codemirror";
|
import { EditorView, SelectionRange } from "@uiw/react-codemirror";
|
||||||
import { useCallback, useEffect, useRef } from "react";
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
|
import { resolveServerPath } from "../api/(client)/client";
|
||||||
|
|
||||||
interface ContextMenuProps {
|
interface ContextMenuProps {
|
||||||
view: EditorView;
|
view: EditorView;
|
||||||
|
|
@ -103,7 +104,10 @@ export const EditorContextMenu = ({
|
||||||
const from = toLineAndColumn(selection.from);
|
const from = toLineAndColumn(selection.from);
|
||||||
const to = toLineAndColumn(selection.to);
|
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}`],
|
['highlightRange', `${from?.line}:${from?.column},${to?.line}:${to?.column}`],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue