Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package/src/native/linux/nativeWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ class ViewsResourceHandler : public CefResourceHandler {
std::string fullPath = "index.html"; // default
if (url.find("views://") == 0) {
fullPath = url.substr(8); // Skip "views://"
// Strip trailing slashes - WebKit may normalize URLs without folder components
while (!fullPath.empty() && (fullPath.back() == '/' || fullPath.back() == '\\')) {
fullPath.pop_back();
}
}

// Check if this is the internal HTML request
Expand Down Expand Up @@ -9788,6 +9792,10 @@ ELECTROBUN_EXPORT void setWindowIcon(void* window, const char* iconPath) {
// Handle views:// protocol
if (actualPath.substr(0, 8) == "views://") {
std::string viewPath = actualPath.substr(8);
// Strip trailing slashes - WebKit may normalize URLs without folder components
while (!viewPath.empty() && (viewPath.back() == '/' || viewPath.back() == '\\')) {
viewPath.pop_back();
}

// Try to load from ASAR archive first if available
if (g_asarArchive) {
Expand Down
8 changes: 8 additions & 0 deletions package/src/native/macos/nativeWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ bool isCEFAvailable() {
while ([relativePath hasPrefix:@"/"]) {
relativePath = [relativePath substringFromIndex:1];
}
// Strip trailing slashes - WebView may normalize URLs without folder components
while ([relativePath hasSuffix:@"/"] && [relativePath length] > 0) {
relativePath = [relativePath substringToIndex:[relativePath length] - 1];
}

return relativePath;
}
Expand Down Expand Up @@ -5625,6 +5629,10 @@ bool Open(CefRefPtr<CefRequest> request,
NSLog(@"DEBUG CEF: Processing views:// URL: %s", urlStr.c_str());
// Remove the prefix (8 characters for "views://") - FIXED VERSION v2
std::string relativePath = urlStr.substr(8);
// Strip trailing slashes - WebView may normalize URLs without folder components
while (!relativePath.empty() && (relativePath.back() == '/' || relativePath.back() == '\\')) {
relativePath.pop_back();
}
NSLog(@"DEBUG CEF FIXED: relativePath = '%s'", relativePath.c_str());

// Check if this is the internal HTML request.
Expand Down
8 changes: 8 additions & 0 deletions package/src/native/win/nativeWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6055,6 +6055,10 @@ static std::shared_ptr<WebView2View> createWebView2View(uint32_t webviewId,

if (uriStr.substr(0, 8) == "views://") {
std::string filePath = uriStr.substr(8);
// Strip trailing slashes - WebView2 may normalize URLs without folder components
while (!filePath.empty() && (filePath.back() == '/' || filePath.back() == '\\')) {
filePath.pop_back();
}
std::string content;

// Check for internal/index.html (inline HTML content)
Expand Down Expand Up @@ -10426,6 +10430,10 @@ void handleViewsSchemeRequest(ICoreWebView2WebResourceRequestedEventArgs* args,
std::string path;
if (uriStr.length() > 8) {
path = uriStr.substr(8); // Remove "views://" prefix
// Strip trailing slashes - WebView2 may normalize URLs without folder components
while (!path.empty() && (path.back() == '/' || path.back() == '\\')) {
path.pop_back();
}
} else {
path = "index.html"; // Default
}
Expand Down