@ai-sdk%[email protected] 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. diff --git a/dist/index.js b/dist/index.js
  2. index 9aa8e83684777e860d905ff7a6895995a7347a4f..820797581ac2a33e731e139da3ebc98b4d93fdcf 100644
  3. --- a/dist/index.js
  4. +++ b/dist/index.js
  5. @@ -395,10 +395,13 @@ function validateDownloadUrl(url) {
  6. message: `Invalid URL: ${url}`
  7. });
  8. }
  9. + if (parsed.protocol === "data:") {
  10. + return;
  11. + }
  12. if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
  13. throw new DownloadError({
  14. url,
  15. - message: `URL scheme must be http or https, got ${parsed.protocol}`
  16. + message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
  17. });
  18. }
  19. const hostname = parsed.hostname;
  20. diff --git a/dist/index.mjs b/dist/index.mjs
  21. index 095fdc188b1d7f227b42591c78ecb71fe2e2cf8b..ca5227d3b6e358aea8ecd85782a0a2b48130a2c9 100644
  22. --- a/dist/index.mjs
  23. +++ b/dist/index.mjs
  24. @@ -299,10 +299,13 @@ function validateDownloadUrl(url) {
  25. message: `Invalid URL: ${url}`
  26. });
  27. }
  28. + if (parsed.protocol === "data:") {
  29. + return;
  30. + }
  31. if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
  32. throw new DownloadError({
  33. url,
  34. - message: `URL scheme must be http or https, got ${parsed.protocol}`
  35. + message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
  36. });
  37. }
  38. const hostname = parsed.hostname;
  39. diff --git a/src/validate-download-url.ts b/src/validate-download-url.ts
  40. index 7c026ad6b400aef551ce3a424c343e1cedc60997..6a2f11398e58f80a8e11995ac1ce5f4d7c110561 100644
  41. --- a/src/validate-download-url.ts
  42. +++ b/src/validate-download-url.ts
  43. @@ -18,11 +18,16 @@ export function validateDownloadUrl(url: string): void {
  44. });
  45. }
  46. - // Only allow http and https protocols
  47. + // data: URLs are inline content and do not make network requests.
  48. + if (parsed.protocol === 'data:') {
  49. + return;
  50. + }
  51. +
  52. + // Only allow http and https network protocols
  53. if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
  54. throw new DownloadError({
  55. url,
  56. - message: `URL scheme must be http or https, got ${parsed.protocol}`,
  57. + message: `URL scheme must be http, https, or data, got ${parsed.protocol}`,
  58. });
  59. }