mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-05 11:08:30 +02:00
refactor: leaner utils.params for relative path
This commit is contained in:
@@ -570,12 +570,7 @@ const utils = {
|
|||||||
params: function (options = {}) {
|
params: function (options = {}) {
|
||||||
let url;
|
let url;
|
||||||
if (options.url && !options.url.startsWith('http')) {
|
if (options.url && !options.url.startsWith('http')) {
|
||||||
// relative path passed in
|
url = new URL(options.url, 'http://dummybase');
|
||||||
const cleanurl = options.url.replace(new RegExp(`/^${(options.relative_path || '')}/`, 'g'), '');
|
|
||||||
url = new URL(document.location);
|
|
||||||
const queryIndex = cleanurl.indexOf('?');
|
|
||||||
url.search = queryIndex !== -1 ? cleanurl.slice(queryIndex) : '';
|
|
||||||
url.pathname = cleanurl;
|
|
||||||
} else {
|
} else {
|
||||||
url = new URL(options.url || document.location);
|
url = new URL(options.url || document.location);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user