diff --git a/netbox/project-static/dist/config.js b/netbox/project-static/dist/config.js index c88353232..079d7b90a 100644 Binary files a/netbox/project-static/dist/config.js and b/netbox/project-static/dist/config.js differ diff --git a/netbox/project-static/dist/config.js.map b/netbox/project-static/dist/config.js.map index 01c611816..3d034b9df 100644 Binary files a/netbox/project-static/dist/config.js.map and b/netbox/project-static/dist/config.js.map differ diff --git a/netbox/project-static/dist/jobs.js b/netbox/project-static/dist/jobs.js index 30794b5f2..74ae33272 100644 Binary files a/netbox/project-static/dist/jobs.js and b/netbox/project-static/dist/jobs.js differ diff --git a/netbox/project-static/dist/jobs.js.map b/netbox/project-static/dist/jobs.js.map index 339676ed1..89a6b6abe 100644 Binary files a/netbox/project-static/dist/jobs.js.map and b/netbox/project-static/dist/jobs.js.map differ diff --git a/netbox/project-static/dist/lldp.js b/netbox/project-static/dist/lldp.js index b194fdc70..0ddfddd27 100644 Binary files a/netbox/project-static/dist/lldp.js and b/netbox/project-static/dist/lldp.js differ diff --git a/netbox/project-static/dist/lldp.js.map b/netbox/project-static/dist/lldp.js.map index cedede19c..179f3b7e9 100644 Binary files a/netbox/project-static/dist/lldp.js.map and b/netbox/project-static/dist/lldp.js.map differ diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 744a9562d..77cf2541c 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 3ac8f3bd7..e47154395 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/dist/status.js b/netbox/project-static/dist/status.js index 13e24ffb2..13c6a7b42 100644 Binary files a/netbox/project-static/dist/status.js and b/netbox/project-static/dist/status.js differ diff --git a/netbox/project-static/dist/status.js.map b/netbox/project-static/dist/status.js.map index a29e1878a..75ee69a42 100644 Binary files a/netbox/project-static/dist/status.js.map and b/netbox/project-static/dist/status.js.map differ diff --git a/netbox/project-static/src/select/api/apiSelect.ts b/netbox/project-static/src/select/api/apiSelect.ts index a7c9ca783..b6e75783a 100644 --- a/netbox/project-static/src/select/api/apiSelect.ts +++ b/netbox/project-static/src/select/api/apiSelect.ts @@ -470,6 +470,7 @@ export class APISelect { break; case 'replace': this.options = options; + break; } if (hasMore(data)) { diff --git a/netbox/project-static/src/util.ts b/netbox/project-static/src/util.ts index 9ba10da8f..99c9d039d 100644 --- a/netbox/project-static/src/util.ts +++ b/netbox/project-static/src/util.ts @@ -1,4 +1,5 @@ import Cookie from 'cookie'; +import queryString from 'query-string'; type Method = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'; type ReqData = URLSearchParams | Dict | undefined | unknown; @@ -127,16 +128,31 @@ function getCsrfToken(): string { * * @param path Relative path _after_ (excluding) the `BASE_PATH`. */ -function buildUrl(path: string): string { +function buildUrl(destination: string): string { + // Separate the path from any URL search params. + const [pathname, search] = destination.split(/(?=\?)/g); + + // If the `origin` exists in the API path (as in the case of paginated responses), remove it. + const origin = new RegExp(window.location.origin, 'g'); + const path = pathname.replaceAll(origin, ''); + const basePath = getBasePath(); + + // Combine `BASE_PATH` with this request's path, removing _all_ slashes. let combined = [...basePath.split('/'), ...path.split('/')].filter(p => p); + if (combined[0] !== '/') { + // Ensure the URL has a leading slash. combined = ['', ...combined]; } if (combined[combined.length - 1] !== '/') { + // Ensure the URL has a trailing slash. combined = [...combined, '']; } - return combined.join('/'); + const url = combined.join('/'); + // Construct an object from the URL search params so it can be re-serialized with the new URL. + const query = Object.fromEntries(new URLSearchParams(search).entries()); + return queryString.stringifyUrl({ url, query }); } export async function apiRequest(