File size: 521 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Get pathname from absolute path.
 *
 * @param absolutePath the absolute path
 * @returns the pathname
 */
export function getPathnameFromAbsolutePath(absolutePath: string) {
  // Remove prefix including app dir
  let appDir = '/app/'
  if (!absolutePath.includes(appDir)) {
    appDir = '\\app\\'
  }
  const [, ...parts] = absolutePath.split(appDir)
  const relativePath = appDir[0] + parts.join(appDir)

  // remove extension
  const pathname = relativePath.split('.').slice(0, -1).join('.')
  return pathname
}