mirror of
https://github.com/qf3l3k/obsidian-data-fetcher.git
synced 2026-07-22 12:20:30 +00:00
Compare commits
No commits in common. "main" and "1.2.0" have entirely different histories.
6 changed files with 11 additions and 46 deletions
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.2.1] - 2026-05-20
|
||||
|
||||
### Fixed
|
||||
- Improved REST response parsing for mobile platforms by handling `Content-Type` headers case-insensitively and falling back to JSON body parsing when the payload is JSON-like. This fixes `path` lookups such as `path: 0` failing on Android and iPad for endpoints that return JSON arrays.
|
||||
|
||||
## [1.2.0] - 2026-05-02
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "data-fetcher",
|
||||
"name": "Data Fetcher",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.0",
|
||||
"minAppVersion": "1.8.3",
|
||||
"description": "Fetch data from multiple sources (REST APIs, RPC, gRPC, GraphQL) and insert results into notes",
|
||||
"author": "qf3l3k",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "obsidian-api-fetcher",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "obsidian-api-fetcher",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-api-fetcher",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.0",
|
||||
"description": "Fetch data from multiple sources (REST APIs, RPC, gRPC, GraphQL) and insert results into notes",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -23,32 +23,6 @@ export interface QueryResult {
|
|||
error?: string;
|
||||
}
|
||||
|
||||
function findHeaderValue(headers: Record<string, string>, targetName: string): string | undefined {
|
||||
const normalizedTarget = targetName.toLowerCase();
|
||||
|
||||
for (const [name, value] of Object.entries(headers || {})) {
|
||||
if (name.toLowerCase() === normalizedTarget) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryParseJsonText(text: string): any | undefined {
|
||||
const trimmed = text.trim();
|
||||
|
||||
if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(trimmed);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function formatRequestError(error: unknown): string {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const normalized = message.toLowerCase();
|
||||
|
|
@ -317,17 +291,14 @@ async function executeRestQuery(params: QueryParams): Promise<any> {
|
|||
|
||||
const response = await requestUrl(requestParams);
|
||||
|
||||
// Mobile builds may expose response headers with different casing, so
|
||||
// treat Content-Type lookup as case-insensitive and fall back to parsing
|
||||
// the body when JSON-looking payloads arrive without a usable header.
|
||||
const contentType = findHeaderValue(response.headers || {}, 'content-type');
|
||||
|
||||
if (contentType && contentType.toLowerCase().includes('application/json')) {
|
||||
// Parse response based on content type
|
||||
const contentType = response.headers['content-type'];
|
||||
|
||||
if (contentType && contentType.includes('application/json')) {
|
||||
return response.json;
|
||||
} else {
|
||||
return response.text;
|
||||
}
|
||||
|
||||
const parsedText = tryParseJsonText(response.text);
|
||||
return parsedText !== undefined ? parsedText : response.text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@
|
|||
"1.1.3": "1.8.3",
|
||||
"1.1.4": "1.8.3",
|
||||
"1.1.5": "1.8.3",
|
||||
"1.2.0": "1.8.3",
|
||||
"1.2.1": "1.8.3"
|
||||
"1.2.0": "1.8.3"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue