Skip to content

Commit

Permalink
URL encode renamer config names to allow usage of '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan committed Jan 9, 2025
1 parent 8ea1236 commit fdae98d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/core/react-query/renamer/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useRenamerRelocateMutation = () =>
mutationFn: (
{ FileIDs, configName, deleteEmptyDirectories, move, rename },
) =>
axios.post(`Renamer/Config/${configName}/Relocate`, FileIDs, {
axios.post(`Renamer/Config/${encodeURIComponent(configName)}/Relocate`, FileIDs, {
params: { deleteEmptyDirectories, move, rename },
}),
onSuccess: updateResults,
Expand All @@ -34,19 +34,21 @@ export const useRenamerRelocateMutation = () =>

export const useRenamerDeleteConfigMutation = () =>
useMutation({
mutationFn: (configName: string) => axios.delete(`Renamer/Config/${configName}`),
mutationFn: (configName: string) => axios.delete(`Renamer/Config/${encodeURIComponent(configName)}`),
onSuccess: () => invalidateQueries(['renamer']),
});

export const useRenamerSaveConfigMutation = () =>
useMutation({
mutationFn: (config: RenamerConfigResponseType) => axios.put(`Renamer/Config/${config.Name}`, config),
mutationFn: (config: RenamerConfigResponseType) =>
axios.put(`Renamer/Config/${encodeURIComponent(config.Name)}`, config),
onSuccess: () => invalidateQueries(['renamer']),
});

export const useRenamerPatchConfigMutation = () =>
useMutation<RenamerConfigType, unknown, RenamerPatchRequestType>({
mutationFn: ({ configName, operations }) => axios.patch(`Renamer/Config/${configName}`, operations),
mutationFn: ({ configName, operations }) =>
axios.patch(`Renamer/Config/${encodeURIComponent(configName)}`, operations),
onMutate: ({ configName, operations }) => {
const data = queryClient.getQueryData<RenamerConfigType[]>(['renamer', 'config'])?.slice();
if (!data) return;
Expand Down
2 changes: 1 addition & 1 deletion src/core/react-query/renamer/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useRenamerConfigsQuery = (enabled = true) =>
export const useRenamerByConfigQuery = (renamerConfig: string, enabled = true) =>
useQuery<RenamerResponseType, unknown, RenamerType>({
queryKey: ['renamer', 'by-config', renamerConfig],
queryFn: () => axios.get(`Renamer/Config/${renamerConfig}/Renamer`),
queryFn: () => axios.get(`Renamer/Config/${encodeURIComponent(renamerConfig)}/Renamer`),
select: transformRenamer,
enabled,
});

0 comments on commit fdae98d

Please sign in to comment.