```ts
/**
 * The text with a character removed from both of its ends, but only one from each end.
 */
export function stripEnds(text: string, mark: string): string {
  if (!text) return text; // Handle empty input

  let out = text;
  while (out.startsWith(mark)) {
    out = out.slice(1);
  }
  while (out.endsWith(mark)) {
    out = out.slice(0, -1);
  }

  return out;
}
```