aboutsummaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2023-11-21 10:55:37 +0100
committerJulien Veyssier <julien-nc@posteo.net>2023-11-27 12:16:24 +0100
commit7741d5cd8f89166d5cc29c3e9736dbb2634847bd (patch)
tree109383488c87d9a292869d309f9991ce4060195a /core/src
parent057daaee9d9377ac9e527e3e45d78be8070c5384 (diff)
downloadnextcloud-server-7741d5cd8f89166d5cc29c3e9736dbb2634847bd.tar.gz
nextcloud-server-7741d5cd8f89166d5cc29c3e9736dbb2634847bd.zip
fix adding x-requested-with header for relative URLs when the base NC URL is empty
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/utils/xhr-request.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/utils/xhr-request.js b/core/src/utils/xhr-request.js
index 66f994246e0..ff8b7641b07 100644
--- a/core/src/utils/xhr-request.js
+++ b/core/src/utils/xhr-request.js
@@ -22,13 +22,24 @@
import { getRootUrl } from '@nextcloud/router'
/**
+ *
+ * @param {string} url the URL to check
+ * @returns {boolean}
+ */
+const isRelativeUrl = (url) => {
+ return !url.startsWith('https://') && !url.startsWith('http://')
+}
+
+/**
* @param {string} url The URL to check
* @return {boolean} true if the URL points to this nextcloud instance
*/
const isNextcloudUrl = (url) => {
const nextcloudBaseUrl = window.location.protocol + '//' + window.location.host + getRootUrl()
- // try with relative and absolute URL
- return url.startsWith(nextcloudBaseUrl) || url.startsWith(getRootUrl())
+ // if the URL is absolute and starts with the baseUrl+rootUrl
+ // OR if the URL is relative and starts with rootUrl
+ return url.startsWith(nextcloudBaseUrl)
+ || (isRelativeUrl(url) && url.startsWith(getRootUrl()))
}
/**