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