mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-23 02:57:07 +00:00
Merge pull request #863 from koteitan/fix/859-strip-trailing-slash-from-uri
fix: strip trailing slash from couchDB_URI to avoid double-slash 401
This commit is contained in:
+2
-2
@@ -138,7 +138,7 @@ export const _requestToCouchDBFetch = async (
|
|||||||
authorization: authHeader,
|
authorization: authHeader,
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
const uri = `${baseUri}/${path}`;
|
const uri = `${baseUri.replace(/\/+$/, "")}/${path}`;
|
||||||
const requestParam = {
|
const requestParam = {
|
||||||
url: uri,
|
url: uri,
|
||||||
method: method || (body ? "PUT" : "GET"),
|
method: method || (body ? "PUT" : "GET"),
|
||||||
@@ -162,7 +162,7 @@ export const _requestToCouchDB = async (
|
|||||||
const authHeaderGen = new AuthorizationHeaderGenerator();
|
const authHeaderGen = new AuthorizationHeaderGenerator();
|
||||||
const authHeader = await authHeaderGen.getAuthorizationHeader(credentials);
|
const authHeader = await authHeaderGen.getAuthorizationHeader(credentials);
|
||||||
const transformedHeaders: Record<string, string> = { authorization: authHeader, origin: origin, ...customHeaders };
|
const transformedHeaders: Record<string, string> = { authorization: authHeader, origin: origin, ...customHeaders };
|
||||||
const uri = `${baseUri}/${path}`;
|
const uri = `${baseUri.replace(/\/+$/, "")}/${path}`;
|
||||||
const requestParam: RequestUrlParam = {
|
const requestParam: RequestUrlParam = {
|
||||||
url: uri,
|
url: uri,
|
||||||
method: method || (body ? "PUT" : "GET"),
|
method: method || (body ? "PUT" : "GET"),
|
||||||
|
|||||||
@@ -781,7 +781,8 @@ Success: ${successCount}, Errored: ${errored}`;
|
|||||||
const credential = generateCredentialObject(this.settings);
|
const credential = generateCredentialObject(this.settings);
|
||||||
const request = async (path: string, method: string = "GET", body: any = undefined) => {
|
const request = async (path: string, method: string = "GET", body: any = undefined) => {
|
||||||
const req = await _requestToCouchDB(
|
const req = await _requestToCouchDB(
|
||||||
this.settings.couchDB_URI + (this.settings.couchDB_DBNAME ? `/${this.settings.couchDB_DBNAME}` : ""),
|
this.settings.couchDB_URI.replace(/\/+$/, "") +
|
||||||
|
(this.settings.couchDB_DBNAME ? `/${this.settings.couchDB_DBNAME}` : ""),
|
||||||
credential,
|
credential,
|
||||||
window.origin,
|
window.origin,
|
||||||
path,
|
path,
|
||||||
|
|||||||
Reference in New Issue
Block a user