Repository navigation
fix(frontend): double prefixed API url - #35641
jakubhruby wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Unescaped regex pattern in applicationRoot replacement ▹ view | ||
| Inefficient regex creation in hot path ▹ view |
Files scanned
| File Path | Reviewed |
|---|---|
| superset-frontend/src/explore/exploreUtils/index.js | ✅ |
| superset-frontend/src/components/Chart/chartAction.js | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| endpointType, | ||
| allowDomainSharding: false, | ||
| }); | ||
| }).replace(new RegExp(`^${applicationRoot()}`), ''); // appRoot will be added in SuperstClient.postForm method |
There was a problem hiding this comment.
Unescaped regex pattern in applicationRoot replacement 
Tell me more
What is the issue?
The regex replacement uses an unescaped applicationRoot() value which could contain special regex characters, potentially causing incorrect string replacement or regex errors.
Why this matters
If applicationRoot() returns a string containing regex metacharacters like '.', '+', '*', '?', '^', '$', '(', ')', '[', ']', '{', '}', '|', '', the regex will not match the intended literal string and may cause unexpected behavior or runtime errors.
Suggested change ∙ Feature Preview
Escape the applicationRoot() value before using it in the regex pattern:
}).replace(new RegExp(`^${applicationRoot().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`), ''); // appRoot will be added in SuperstClient.postForm methodAlternatively, use a simpler string-based approach:
const appRoot = applicationRoot();
if (url.startsWith(appRoot)) {
url = url.substring(appRoot.length);
}Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
| endpointType, | ||
| allowDomainSharding: false, | ||
| }); | ||
| }).replace(new RegExp(`^${applicationRoot()}`), ''); // appRoot will be added in SuperstClient.postForm method |
There was a problem hiding this comment.
Inefficient regex creation in hot path 
Tell me more
What is the issue?
Regular expression is created on every function call instead of being cached or using a more efficient string operation.
Why this matters
Creating a new RegExp object on each function execution adds unnecessary overhead, especially if exportChart is called frequently. This impacts performance through repeated object instantiation and regex compilation.
Suggested change ∙ Feature Preview
Cache the regex pattern outside the function or use string methods like startsWith() and slice() for better performance:
const APP_ROOT_REGEX = new RegExp(`^${applicationRoot()}`);
// Then use: url.replace(APP_ROOT_REGEX, '')
// Or better: url.startsWith(appRoot) ? url.slice(appRoot.length) : urlProvide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
|
@jakubhruby — friendly ping on this one. It's been sitting for a few months and has picked up some blockers:
If you're still interested in landing this fix, could you rebase and push? Otherwise we can close it out and revisit later. No rush — just trying to keep the queue tidy. |
|
Duplicated and replaced by #38513 |
|
closing |
SUMMARY
When app root prefix is applied (e.g.
SUPERSET_APP_ROOT="/app-prefix"), it's applied twice - e.g. when exporting graph to CSVBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Test downloading CSV file.
ADDITIONAL INFORMATION