Don't require versionBase in docsURL

In https://github.com/syncthing/syncthing/pull/9175 we will sometimes want to
show links to the documentation on the login page. These links currently get
truncated to just `https://docs.syncthing.net`, discarding the section path,
because the server version is not yet known while on the login page.

I don't think it's any worse to try to preserve the section path even without an
explicit version tag, than to fall back to just the host and lose all context
the link was attempting to provide.
This commit is contained in:
Emil Lundberg 2024-09-21 19:23:48 +02:00
parent 9adb239662
commit 44fef31780
No known key found for this signature in database
GPG Key ID: BFD86BE9948C849A

View File

@ -3301,16 +3301,16 @@ angular.module('syncthing.core')
$scope.docsURL = function (path) {
var url = 'https://docs.syncthing.net';
if (!$scope.versionBase()) {
return url;
}
if (!path) {
// Undefined or null should become a valid string.
path = '';
}
var hashIndex = path.indexOf('#');
url += '/' + (hashIndex === -1 ? path : path.slice(0, hashIndex));
url += '?version=' + $scope.versionBase();
var ver = $scope.versionBase();
if (ver) {
url += '?version=' + ver;
}
var hash = hashIndex === -1 ? '' : path.slice(hashIndex);
if (hash) {
url += hash;