We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef35c89 commit f294c17Copy full SHA for f294c17
src/main.js
@@ -102,7 +102,16 @@ if (typeof Yasgui !== "undefined") {
102
throw new Error(`HTTP error! status: ${response.status}`);
103
}
104
105
- const data = await response.json();
+ // Get response as text first to handle potential PHP warnings
106
+ const responseText = await response.text();
107
+
108
+ // Extract JSON object from response (ignore any PHP warnings/HTML before it)
109
+ const jsonMatch = responseText.match(/\{.*\}/s);
110
+ if (!jsonMatch) {
111
+ throw new Error('No JSON object found in response');
112
+ }
113
114
+ const data = JSON.parse(jsonMatch[0]);
115
116
if (data.status === 'fail') {
117
throw new Error(data.message || 'Failed to shorten URL');
0 commit comments