```ts
/** The text with a character removed from both of its ends. */
export function stripEnds(text: string, mark: string): string {
  if (text.startsWith(mark)) {
    text = text.slice(1);
  }
  if (text.endsWith(mark)) {
    text = text.slice(0, -1);
  }
  return text;
}
```