mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
App: encode primary key (#5143)
* app: encode primary key Since primary keys could be manually entered strings, we should encode those in order to prevent accessing inexistent routes. E.g. Document with primary key: 'clients/John Doe' * fixup! app: encode primary key Since primary keys could be manually entered strings, we should encode those in order to prevent accessing inexistent routes. E.g. Document with primary key: 'clients/John Doe' Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -43,7 +43,7 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
|
||||
return endpoint.value;
|
||||
}
|
||||
|
||||
return `${endpoint.value}/${primaryKey.value}`;
|
||||
return `${endpoint.value}/${encodeURIComponent(primaryKey.value as string)}`;
|
||||
});
|
||||
|
||||
watch([collection, primaryKey], refresh, { immediate: true });
|
||||
|
||||
@@ -25,7 +25,7 @@ export default function useTemplateData(collection: ComputedRef<Collection | und
|
||||
|
||||
const endpoint = collection.value.collection.startsWith('directus_')
|
||||
? `/${collection.value.collection.substring(9)}/${primaryKey.value}`
|
||||
: `/items/${collection.value.collection}/${primaryKey.value}`;
|
||||
: `/items/${collection.value.collection}/${encodeURIComponent(primaryKey.value)}`;
|
||||
|
||||
try {
|
||||
const result = await api.get(endpoint, {
|
||||
|
||||
Reference in New Issue
Block a user