@umbraco-cms/backoffice
    Preparing search index...

    Function truncateString

    • Shortens a string to a maximum length by replacing its middle with a separator, keeping the start and the end.

      Parameters

      • input: string | undefined

        The string to shorten.

      • maxLength: number

        The maximum length of the result, including the separator.

      • Optionalseparator: string = '…'

        The text that replaces the removed characters.

      Returns string

      The input if it fits within maxLength, otherwise the shortened string. An empty string if no input is given.

      truncateString('A very long document name', 15) // "A very…nt name"