e621 3.2.1 → 3.2.2
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/browser/e621.js +10 -3
- package/dist/browser/e621.js.map +2 -2
- package/dist/lib/client.d.ts +7 -0
- package/dist/lib/client.js +9 -2
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/package.json +1 -1
package/dist/browser/e621.js
CHANGED
|
@@ -787,7 +787,7 @@ var createClient = (config = {}) => {
|
|
|
787
787
|
};
|
|
788
788
|
|
|
789
789
|
// dist/lib/version.js
|
|
790
|
-
var VERSION = "3.2.
|
|
790
|
+
var VERSION = "3.2.2";
|
|
791
791
|
|
|
792
792
|
// dist/lib/client.js
|
|
793
793
|
function createE621Client(options) {
|
|
@@ -797,12 +797,13 @@ function createE621Client(options) {
|
|
|
797
797
|
baseURL: options?.baseURL ?? "https://e621.net",
|
|
798
798
|
requestTimeout: options?.requestTimeout ?? 30,
|
|
799
799
|
statusCheckURL: options?.statusCheckURL ?? "https://status.e621.church/json",
|
|
800
|
-
userAgent: options?.userAgent ?? `E621/${VERSION} (https://github.com/DonovanDMC/E621${options?.authUser ? `; "${options.authUser}"` : ""})
|
|
800
|
+
userAgent: options?.userAgent ?? `E621/${VERSION} (https://github.com/DonovanDMC/E621${options?.authUser ? `; "${options.authUser}"` : ""})`,
|
|
801
|
+
userAgentInQuery: options?.userAgentInQuery ?? "window" in globalThis
|
|
801
802
|
};
|
|
802
803
|
let config;
|
|
803
804
|
const commonConfig = {
|
|
804
805
|
baseUrl: resolved.baseURL,
|
|
805
|
-
headers: {
|
|
806
|
+
headers: resolved.userAgentInQuery ? void 0 : {
|
|
806
807
|
"User-Agent": resolved.userAgent
|
|
807
808
|
},
|
|
808
809
|
fetch: async (input, init) => {
|
|
@@ -824,6 +825,12 @@ function createE621Client(options) {
|
|
|
824
825
|
init.headers = headers;
|
|
825
826
|
}
|
|
826
827
|
}
|
|
828
|
+
if (resolved.userAgentInQuery && input instanceof Request) {
|
|
829
|
+
const requestURL = new URL(input.url);
|
|
830
|
+
requestURL.searchParams.set("_client", resolved.userAgent);
|
|
831
|
+
input = new Request(requestURL, input);
|
|
832
|
+
url = requestURL.toString();
|
|
833
|
+
}
|
|
827
834
|
Debug(`request:${method}`, `-> ${url}`);
|
|
828
835
|
const res = await fetch(input, init);
|
|
829
836
|
Debug(`response:${method}`, `<- ${url} ${res.status} ${res.statusText}`);
|