mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Merge pull request #41732 from nextcloud/backport/41632/stable28
[stable28] Fix adding x-requested-with header for relative URLs in some cases
This commit is contained in:
commit
4342a48798
3 changed files with 16 additions and 5 deletions
|
|
@ -21,14 +21,25 @@
|
|||
|
||||
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()))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
4
dist/core-main.js
vendored
4
dist/core-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-main.js.map
vendored
2
dist/core-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue