Files
twenty/packages/twenty-server/src/engine/metadata-modules/flat-object-metadata/utils/search-and-replace-last.util.ts
T
Guillim f60817a1e1 Morph many to one picker (#14155)
This PR follows the multiSelect PR merged previously. It will enable
morph relation Many to One to be handled from the table, using a
singleSelect picker

Main point : I decided to change the singleSelect API to take an array
of **objectMetadataName** instead of only one to deal with both our
usecases.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2025-10-07 17:25:11 +02:00

20 lines
337 B
TypeScript

export const searchAndReplaceLast = ({
replace,
search,
source,
}: {
source: string;
search: string;
replace: string;
}) => {
const lastIndex = source.lastIndexOf(search);
if (lastIndex === -1) return source;
return (
source.slice(0, lastIndex) +
replace +
source.slice(lastIndex + search.length)
);
};