Preserve trailing slashes in constructed URLs within buildPathname for improved URL consistency.
This commit is contained in:
+5
-3
@@ -22,8 +22,9 @@ function isSameOriginBaseUrl(baseUrl) {
|
||||
|
||||
function buildPathname({ database, kitchenId, path, includeKitchen = true }) {
|
||||
const encodedDatabase = encodeURIComponent(database);
|
||||
const encodedPathSegments = String(path || '')
|
||||
.replace(/^\/+/, '')
|
||||
const rawPath = String(path || '').replace(/^\/+/, '');
|
||||
const keepTrailingSlash = rawPath.endsWith('/');
|
||||
const encodedPathSegments = rawPath
|
||||
.split('/')
|
||||
.filter(Boolean)
|
||||
.map((segment) => encodeURIComponent(segment));
|
||||
@@ -35,7 +36,8 @@ function buildPathname({ database, kitchenId, path, includeKitchen = true }) {
|
||||
|
||||
segments.push(...encodedPathSegments);
|
||||
|
||||
return `/${segments.join('/')}`;
|
||||
const pathname = `/${segments.join('/')}`;
|
||||
return keepTrailingSlash ? `${pathname}/` : pathname;
|
||||
}
|
||||
|
||||
function buildUrl({ baseUrl, database, kitchenId, path, query = {}, includeKitchen = true }) {
|
||||
|
||||
Reference in New Issue
Block a user