File size: 449 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { parsePath } from './parse-path'

/**
 * Similarly to `addPathPrefix`, this function adds a suffix at the end on the
 * provided path. It also works only for paths ensuring the argument starts
 * with a slash.
 */
export function addPathSuffix(path: string, suffix?: string) {
  if (!path.startsWith('/') || !suffix) {
    return path
  }

  const { pathname, query, hash } = parsePath(path)
  return `${pathname}${suffix}${query}${hash}`
}