Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append trailing slash to URL if missing #14822

Closed
wants to merge 1 commit into from
Closed
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 src/webui/www/private/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
<html lang="${LANG}">

<head>
<script>
let path = window.location.pathname;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use const:
const path = ...

if (path) {
let lastChar = path.substr(path.length - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substr is not recommended: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr#browser_compatibility
I would suggest: const lastChar = path.slice(-1);

if (lastChar != '/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (lastChar !== '/')

window.location.replace(window.location.href + '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this redirection break other things? such as the magnet handler?

}
</script>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<title>qBittorrent Web UI</title>
Expand Down
8 changes: 8 additions & 0 deletions src/webui/www/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
<html lang="${LANG}">

<head>
<script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it to the next line of </noscript>.
The same for private/index.html.

let path = window.location.pathname;
if (path) {
let lastChar = path.substr(path.length - 1);
if (lastChar != '/')
window.location.replace(window.location.href + '/');
}
</script>
<meta charset="UTF-8" />
<title>qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]</title>
<link rel="icon" type="image/png" href="images/qbittorrent32.png" />
Expand Down