unified requrl everywhere
This commit is contained in:
parent
39a33243e8
commit
e03522efe4
@ -3,6 +3,7 @@
|
||||
* To avoid circular dependency.
|
||||
*/
|
||||
|
||||
import { Platform, requireApiVersion } from "obsidian";
|
||||
import type { LangType, LangTypeAndAuto } from "./i18n";
|
||||
|
||||
export const DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
||||
@ -148,3 +149,5 @@ export interface FileOrFolderMixedState {
|
||||
|
||||
export const API_VER_STAT_FOLDER = "0.13.27";
|
||||
export const API_VER_REQURL = "0.13.26";
|
||||
export const VALID_REQURL =
|
||||
requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp;
|
||||
|
||||
@ -22,19 +22,13 @@ import { buildQueryString } from "@aws-sdk/querystring-builder";
|
||||
import { HeaderBag, HttpHandlerOptions, Provider } from "@aws-sdk/types";
|
||||
import { Buffer } from "buffer";
|
||||
import * as mime from "mime-types";
|
||||
import {
|
||||
Vault,
|
||||
requestUrl,
|
||||
RequestUrlParam,
|
||||
RequestUrlResponse,
|
||||
requireApiVersion,
|
||||
} from "obsidian";
|
||||
import { Vault, requestUrl, RequestUrlParam } from "obsidian";
|
||||
import { Readable } from "stream";
|
||||
import {
|
||||
API_VER_REQURL,
|
||||
DEFAULT_CONTENT_TYPE,
|
||||
RemoteItem,
|
||||
S3Config,
|
||||
VALID_REQURL,
|
||||
} from "./baseTypes";
|
||||
import { decryptArrayBuffer, encryptArrayBuffer } from "./encrypt";
|
||||
import {
|
||||
@ -194,7 +188,7 @@ export const getS3Client = (s3Config: S3Config) => {
|
||||
endpoint = `https://${endpoint}`;
|
||||
}
|
||||
|
||||
if (requireApiVersion(API_VER_REQURL) && s3Config.bypassCorsLocally) {
|
||||
if (VALID_REQURL && s3Config.bypassCorsLocally) {
|
||||
const s3Client = new S3Client({
|
||||
region: s3Config.s3Region,
|
||||
endpoint: endpoint,
|
||||
|
||||
@ -1,19 +1,11 @@
|
||||
import { Buffer } from "buffer";
|
||||
import {
|
||||
Vault,
|
||||
request,
|
||||
requestUrl,
|
||||
requireApiVersion,
|
||||
Platform,
|
||||
Notice,
|
||||
RequestUrlResponse,
|
||||
} from "obsidian";
|
||||
import { Vault, requestUrl } from "obsidian";
|
||||
|
||||
import { Queue } from "@fyears/tsqueue";
|
||||
import chunk from "lodash/chunk";
|
||||
import flatten from "lodash/flatten";
|
||||
import { getReasonPhrase } from "http-status-codes";
|
||||
import { API_VER_REQURL, RemoteItem, WebdavConfig } from "./baseTypes";
|
||||
import { RemoteItem, VALID_REQURL, WebdavConfig } from "./baseTypes";
|
||||
import { decryptArrayBuffer, encryptArrayBuffer } from "./encrypt";
|
||||
import { bufferToArrayBuffer, getPathFolder, mkdirpInVault } from "./misc";
|
||||
|
||||
@ -28,7 +20,7 @@ import type {
|
||||
ResponseDataDetailed,
|
||||
} from "webdav/web";
|
||||
import { getPatcher } from "webdav/web";
|
||||
if (requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp) {
|
||||
if (VALID_REQURL) {
|
||||
getPatcher().patch(
|
||||
"request",
|
||||
async (
|
||||
|
||||
@ -11,6 +11,7 @@ import {
|
||||
API_VER_REQURL,
|
||||
SUPPORTED_SERVICES_TYPE,
|
||||
SUPPORTED_SERVICES_TYPE_WITH_REMOTE_BASE_DIR,
|
||||
VALID_REQURL,
|
||||
WebdavAuthType,
|
||||
WebdavDepthType,
|
||||
} from "./baseTypes";
|
||||
@ -747,7 +748,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
}
|
||||
|
||||
if (!requireApiVersion(API_VER_REQURL)) {
|
||||
if (!VALID_REQURL) {
|
||||
s3Div.createEl("p", {
|
||||
text: t("settings_s3_cors"),
|
||||
});
|
||||
@ -769,7 +770,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
text: t("settings_s3_prod2"),
|
||||
});
|
||||
|
||||
if (!requireApiVersion(API_VER_REQURL)) {
|
||||
if (!VALID_REQURL) {
|
||||
s3LinksUl.createEl("li").createEl("a", {
|
||||
href: "https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html",
|
||||
text: t("settings_s3_prod3"),
|
||||
@ -862,7 +863,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
if (requireApiVersion(API_VER_REQURL)) {
|
||||
if (VALID_REQURL) {
|
||||
new Setting(s3Div)
|
||||
.setName(t("settings_s3_bypasscorslocally"))
|
||||
.setDesc(
|
||||
@ -1277,9 +1278,6 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.serviceType !== "webdav"
|
||||
);
|
||||
|
||||
const webdavReq =
|
||||
requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp;
|
||||
|
||||
webdavDiv.createEl("h2", { text: t("settings_webdav") });
|
||||
|
||||
webdavDiv.createEl("p", {
|
||||
@ -1287,7 +1285,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
cls: "webdav-disclaimer",
|
||||
});
|
||||
|
||||
if (!webdavReq) {
|
||||
if (!VALID_REQURL) {
|
||||
if (Platform.isAndroidApp) {
|
||||
webdavDiv.createEl("p", {
|
||||
text: t("settings_webdav_cors_android"),
|
||||
@ -1372,12 +1370,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
.setDesc(t("settings_webdav_auth_desc"))
|
||||
.addDropdown(async (dropdown) => {
|
||||
dropdown.addOption("basic", "basic");
|
||||
if (webdavReq) {
|
||||
if (VALID_REQURL) {
|
||||
dropdown.addOption("digest", "digest");
|
||||
}
|
||||
|
||||
// new version config, copied to old version, we need to reset it
|
||||
if (!webdavReq && this.plugin.settings.webdav.authType !== "basic") {
|
||||
if (!VALID_REQURL && this.plugin.settings.webdav.authType !== "basic") {
|
||||
this.plugin.settings.webdav.authType = "basic";
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
@ -1475,7 +1473,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
if (res) {
|
||||
new Notice(t("settings_webdav_connect_succ"));
|
||||
} else {
|
||||
if (webdavReq) {
|
||||
if (VALID_REQURL) {
|
||||
new Notice(t("settings_webdav_connect_fail"));
|
||||
} else {
|
||||
new Notice(t("settings_webdav_connect_fail_withcors"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user