mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
16 lines
520 B
TypeScript
16 lines
520 B
TypeScript
import {middleEllipsis} from 'sentry/utils/middleEllipsis';
|
|
|
|
/**
|
|
* Trim slug name with a preference for preserving whole words. Only cut up
|
|
* whole words if the last remaining words are still too long.
|
|
*
|
|
* For example:
|
|
*
|
|
* javascript-project-backend -> javascript…backend
|
|
* my-long-sentry-project-name -> my-long…project-name
|
|
* javascriptproject-backend -> javascriptproj…ackend
|
|
*/
|
|
export function trimSlug(slug: string, maxLength: number = 20) {
|
|
return middleEllipsis(slug, maxLength, '-');
|
|
}
|