aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/OC/webroot.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/OC/webroot.js')
-rw-r--r--core/src/OC/webroot.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/src/OC/webroot.js b/core/src/OC/webroot.js
new file mode 100644
index 00000000000..cbe5a6190e1
--- /dev/null
+++ b/core/src/OC/webroot.js
@@ -0,0 +1,18 @@
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+let webroot = window._oc_webroot
+
+if (typeof webroot === 'undefined') {
+ webroot = location.pathname
+ const pos = webroot.indexOf('/index.php/')
+ if (pos !== -1) {
+ webroot = webroot.substr(0, pos)
+ } else {
+ webroot = webroot.substr(0, webroot.lastIndexOf('/'))
+ }
+}
+
+export default webroot