@gitterm/sdk 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -450,6 +450,10 @@ function errorCode(code) {
|
|
|
450
450
|
return code;
|
|
451
451
|
return "SERVER_ERROR";
|
|
452
452
|
}
|
|
453
|
+
function toWorkspaceTrpcUrl(serverUrl) {
|
|
454
|
+
const url = new URL(serverUrl);
|
|
455
|
+
return url.pathname.endsWith("/trpc") ? serverUrl : new URL("/trpc", url).toString();
|
|
456
|
+
}
|
|
453
457
|
function createGittermWorkspaceClient(options = {}) {
|
|
454
458
|
const detected = options.serverUrl && options.token && options.workspaceId ? null : getWorkspaceEnvironment();
|
|
455
459
|
const rawServerUrl = options.serverUrl ?? detected?.serverUrl;
|
|
@@ -462,7 +466,7 @@ function createGittermWorkspaceClient(options = {}) {
|
|
|
462
466
|
const trpc = createTRPCClient2({
|
|
463
467
|
links: [
|
|
464
468
|
httpBatchLink2({
|
|
465
|
-
url:
|
|
469
|
+
url: toWorkspaceTrpcUrl(serverUrl),
|
|
466
470
|
fetch: createNoRedirectFetch(options.fetch),
|
|
467
471
|
headers: () => ({ authorization: `Bearer ${token}` })
|
|
468
472
|
})
|