bito-code-review[bot] commented on code in PR #36771:
URL: https://github.com/apache/superset/pull/36771#discussion_r2663141934
##########
superset-frontend/src/components/StreamingExportModal/useStreamingExport.ts:
##########
@@ -39,6 +51,45 @@ interface StreamingExportParams {
const NEWLINE_BYTE = 10; // '\n' character code
+/**
+ * Ensures URL has the application root prefix for subdirectory deployments.
+ * Applies makeUrl to relative paths that don't already include the app root.
+ * This guards against callers forgetting to prefix URLs when using native
fetch.
+ */
+const ensureUrlPrefix = (url: string): string => {
+ const appRoot = applicationRoot();
+ // Protocol-relative URLs (//example.com/...) should pass through unchanged
+ if (url.startsWith('//')) {
+ return url;
+ }
+ // Absolute URLs (http:// or https://) should pass through unchanged
+ if (url.match(/^https?:\/\//)) {
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incomplete absolute URL detection</b></div>
<div id="fix">
The regex `/^https?:\/\//` only matches http/https URLs, but absolute URLs
with other protocols (e.g., ftp://) would be incorrectly prefixed with `/`. Use
`url.includes('://')` for broader protocol support.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
---
a/superset-frontend/src/components/StreamingExportModal/useStreamingExport.ts
+++
b/superset-frontend/src/components/StreamingExportModal/useStreamingExport.ts
@@ -65,7 +65,7 @@ const ensureUrlPrefix = (url: string): string => {
// Absolute URLs (http:// or https://) should pass through unchanged
- if (url.match(/^https?:\/\//)) {
+ if (url.includes('://')) {
return url;
}
// Relative URLs without leading slash (e.g., "api/v1/...") need
normalization
```
</div>
</details>
</div>
<small><i>Code Review Run #97f367</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]