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
16 changes: 12 additions & 4 deletions src/pages/fileBrowser/fileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,14 +1333,16 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
* @param {String} url
*/
function pushToNavbar(name, url, action) {
if (!url) return;
const displayName = name || Url.basename(url) || url;
$navigation.append(
<span
id={getNavId(url)}
className="nav"
data-url={url}
data-name={name}
data-name={displayName}
attr-action="navigation"
attr-text={name}
attr-text={displayName}
tabIndex={-1}
></span>,
);
Expand All @@ -1359,14 +1361,20 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
* @param {Array<Location>} states
*/
function loadStates(states) {
if (!Array.isArray(states)) return;
if (!Array.isArray(states) || !states.length) return;

const backNavigation = [];
const { url, name } = states.pop();
const lastState = states.pop();
if (!lastState || !lastState.url) return;
const { url } = lastState;
const name = lastState.name || Url.basename(url) || url;
let { url: lastUrl, name: lastName } = currentDir;

while (states.length) {
const location = states.splice(0, 1)[0];
if (!location || !location.url) {
continue;
}
const { url, name } = location;
let action;

Expand Down
29 changes: 22 additions & 7 deletions src/plugins/system/android/com/foxdebug/system/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,29 @@ private void hasPermission(String permission, CallbackContext callback) {
}

public boolean fileExists(String path, String countSymlinks) {
Path p = new File(path).toPath();
boolean followSymlinks = !Boolean.parseBoolean(countSymlinks);
File file = new File(path);

// Android < O does not implement File#toPath(), fall back to legacy checks
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (!file.exists()) return false;
if (followSymlinks) {
try {
// If canonical and absolute paths differ, it's a symlink
return file.getCanonicalPath().equals(file.getAbsolutePath());
} catch (IOException ignored) {
return false;
}
}
return true;
}

Path p = file.toPath();
try {
if (Boolean.parseBoolean(countSymlinks)) {
// This will return true even for broken symlinks
return Files.exists(p, LinkOption.NOFOLLOW_LINKS);
} else {
// Check target file, not symlink itself
if (followSymlinks) {
return Files.exists(p) && !Files.isSymbolicLink(p);
} else {
return Files.exists(p, LinkOption.NOFOLLOW_LINKS);
}
} catch (Exception e) {
return false;
Expand Down Expand Up @@ -1301,4 +1316,4 @@ private void setInputType(String type) {
}
webView.setInputType(mode);
}
}
}
12 changes: 10 additions & 2 deletions src/plugins/websocket/www/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ class WebSocketInstance extends EventTarget {

if (event.type === 'close') {
this.readyState = WebSocketInstance.CLOSED;
const closeEvent = new CloseEvent('close', { code: event.data?.code, reason: event.data?.reason });
const closeData = event && event.data ? event.data : {};
const closeEvent = new CloseEvent('close', {
code: closeData.code,
reason: closeData.reason,
});
if (this.onclose) this.onclose(closeEvent);
this.dispatchEvent(closeEvent);
}

if (event.type === 'error') {
const errorEvent = new Event('error', { message: event?.data });
const errorMessage = event && event.data ? event.data : undefined;
const errorEvent = new Event('error');
if (errorMessage !== undefined) {
errorEvent.message = errorMessage;
}
if (this.onerror) this.onerror(errorEvent);
this.dispatchEvent(errorEvent);
}
Expand Down
6 changes: 3 additions & 3 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
type,
listener,
useCapture,
allowed,
allowed
) {
if (typeof useCapture === "boolean") {
allowed = useCapture;
Expand Down Expand Up @@ -76,7 +76,7 @@
}
this.eventListeners[type].push({
listener: listener,
useCapture: useCapture,
useCapture: useCapture
});

return;
Expand Down Expand Up @@ -159,4 +159,4 @@
<wc-page id="root" class="primary"></wc-page>
</body>

</html>
</html>