mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-30 04:39:04 +00:00
Strip the trailing slash from the direct search API URL (#4861)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Strip the trailing slash from the API URL used by browser site search.
|
||||
@@ -3,10 +3,10 @@ import { afterEach, describe, expect, it, spyOn } from 'bun:test';
|
||||
import { SEARCH_FALLBACK_HEADER, createSearchPassStore } from './search-pass-store';
|
||||
import type { DirectSearchProps } from '@/lib/search-results';
|
||||
|
||||
const endpoint = 'https://api.gitbook.com/v1/orgs/org_1/sites/site_1/search';
|
||||
const endpoint = 'https://api.gitbook.com/cache/v1/orgs/org_1/sites/site_1/search';
|
||||
const proxyURL = '/~gitbook/search-direct/orgs/org_1/sites/site_1';
|
||||
const directSearch: DirectSearchProps = {
|
||||
apiURL: 'https://api.gitbook.com',
|
||||
apiURL: 'https://api.gitbook.com/cache/',
|
||||
organizationId: 'org_1',
|
||||
siteId: 'site_1',
|
||||
proxyURL,
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { SearchRecordResult, SearchSpaceResult } from '@gitbook/api';
|
||||
import type { OrderedComputedResult, SearchSiteContentScope } from './search-types';
|
||||
import { getEmbeddableLinker } from '@/lib/embeddable-linker';
|
||||
import { createSiteLinker } from '@/lib/links';
|
||||
import { removeTrailingSlash } from '@/lib/paths';
|
||||
import {
|
||||
type DirectSearchProps,
|
||||
computePublishedSearchResults,
|
||||
@@ -157,7 +158,7 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
let pass = state;
|
||||
const { apiURL, organizationId, siteId, proxyURL } = directSearch;
|
||||
const usingProxy = useProxy;
|
||||
let url = `${apiURL}/v1/orgs/${organizationId}/sites/${siteId}/search`;
|
||||
let url = `${removeTrailingSlash(apiURL)}/v1/orgs/${organizationId}/sites/${siteId}/search`;
|
||||
if (usingProxy) {
|
||||
url = proxyURL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user