mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-06 20:13:35 +09:00
fix: trim url for cloudflare worker (#2830)
Fixes https://discord.com/channels/955905230107738152/1199803387005390858/1199803387005390858 Here fixed the issue with leading spaces in resource urls fail when fetch in workers. Trimmed urls and added validation for urls.
This commit is contained in:
1 parent
2816784602
commit
4ef839aba7
2 files changed
+8
-1
No files matched your search
@@ -309,6 +309,11 @@ export const ResourceForm = forwardRef<
|
||||
if (evaluatedValue.length === 0) {
|
||||
return "URL is required";
|
||||
}
|
||||
try {
|
||||
new URL(evaluatedValue);
|
||||
} catch {
|
||||
return "URL is invalid";
|
||||
}
|
||||
},
|
||||
});
|
||||
const [method, setMethod] = useState<Resource["method"]>(
|
||||
|
||||
@@ -13,7 +13,9 @@ export const loadResource = async (resourceData: Resource) => {
|
||||
requestInit.body = body;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(url, requestInit);
|
||||
// cloudflare workers fail when fetching url contains spaces
|
||||
// even though new URL suppose to trim them on parsing by spec
|
||||
const response = await fetch(url.trim(), requestInit);
|
||||
let data;
|
||||
if (
|
||||
response.ok &&
|
||||
|
||||
Reference in new issue
Block a user