@jeniex/utils 1.0.19 → 1.0.20

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/browser/index.cjs CHANGED
@@ -111,7 +111,7 @@ function prompt(message, _default) {
111
111
 
112
112
  async function fishResponse(url, options) {
113
113
  const response = await fetch(url, options);
114
- if (!response.ok) {
114
+ if (!response.ok && !response.url.startsWith('file:///')) {
115
115
  throw new Error(`Request to ${response.url} ended with ${response.status} status.`);
116
116
  }
117
117
  return response;
@@ -131,14 +131,15 @@ async function fishXResponse(url, fishOptions) {
131
131
  timeout: timeOut,
132
132
  onprogress: onProgress,
133
133
  onload({ response, statusText, status, finalUrl }) {
134
+ const isFileURL = finalUrl.startsWith('file:///');
134
135
  const ok = status >= 200 && status < 300;
135
- if (!ok) {
136
+ if (!ok && !isFileURL) {
136
137
  reject(new Error(`Request to ${url} ended with ${status} status.`));
137
138
  return;
138
139
  }
139
140
  const properResponse = new Response(response, {
140
141
  statusText,
141
- status,
142
+ status: isFileURL ? 200 : status,
142
143
  });
143
144
  Object.defineProperty(properResponse, 'url', { value: finalUrl });
144
145
  resolve(properResponse);
package/browser/index.js CHANGED
@@ -109,7 +109,7 @@ function prompt(message, _default) {
109
109
 
110
110
  async function fishResponse(url, options) {
111
111
  const response = await fetch(url, options);
112
- if (!response.ok) {
112
+ if (!response.ok && !response.url.startsWith('file:///')) {
113
113
  throw new Error(`Request to ${response.url} ended with ${response.status} status.`);
114
114
  }
115
115
  return response;
@@ -129,14 +129,15 @@ async function fishXResponse(url, fishOptions) {
129
129
  timeout: timeOut,
130
130
  onprogress: onProgress,
131
131
  onload({ response, statusText, status, finalUrl }) {
132
+ const isFileURL = finalUrl.startsWith('file:///');
132
133
  const ok = status >= 200 && status < 300;
133
- if (!ok) {
134
+ if (!ok && !isFileURL) {
134
135
  reject(new Error(`Request to ${url} ended with ${status} status.`));
135
136
  return;
136
137
  }
137
138
  const properResponse = new Response(response, {
138
139
  statusText,
139
- status,
140
+ status: isFileURL ? 200 : status,
140
141
  });
141
142
  Object.defineProperty(properResponse, 'url', { value: finalUrl });
142
143
  resolve(properResponse);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeniex/utils",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "author": "JenieX",
5
5
  "homepage": "https://github.com/JenieX/utils",
6
6
  "type": "module",