Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

  • combinePaths(path1: string, path2: string): string
  • Concatenates two paths, using '' character

    example
    combinePaths('end with slash\\', '\\start with slash'); // '\end with slash\start with slash\'
    combinePaths('test path', 'test\\path'); // '\test path\test\path\'

    Parameters

    • path1: string
    • path2: string

    Returns string

    the concatenated file path

  • createDisplayPath(path: string): string
  • Ensures the path starts and ends with ''

    example
    createDisplayPath('\\'); // '\'
    createDisplayPath('hi'); // '\hi\'
    createDisplayPath('hi\\'); // '\hi\'
    createDisplayPath('hi\\world'); // '\hi\world\'

    Parameters

    • path: string

    Returns string

    path with ''

  • getCleanedExtension(extension: undefined | string): string | undefined
  • Prepends a dot to file extension if dot doesn't exist

    example
    getCleanedExtension(''); // undefined
    getCleanedExtension('a'); // '.a'
    getCleanedExtension('.a'); // '.a'
    getCleanedExtension('a.b'); // '.a.b'
    getCleanedExtension('.a.b'); // '.a.b'

    Parameters

    • extension: undefined | string

    Returns string | undefined

    file extension with a dot

  • getFileExtension(fileName: string): string | undefined
  • Returns the file extension of a file, or undefined

    example
    getFileExtension('test.ext'); // 'ext'
    getFileExtension('test.doc.ext'); // 'ext'
    getFileExtension('test'); // undefined

    Parameters

    • fileName: string

    Returns string | undefined

    the file extension, or undefined

  • getLastPathSegment(path: string): string
  • Returns the last past segment for a '' delimited string

    example
    getLastPathSegment('\\hello\\world\\'); // 'world'
    getLastPathSegment('\\hello\\'); // 'hello'
    getLastPathSegment('\\hello\\\\'); // ''

    Parameters

    • path: string

      to a folder or a file

    Returns string

    the last segment

  • getListOfFolderNames(path: string): string[]
  • Returns the path segments as an array

    example
    getListOfFolderNames('\\'); // []
    getListOfFolderNames(''); // []
    getListOfFolderNames('\\hello'); // ['hello']
    getListOfFolderNames('\\hello\\world'); // ['hello', 'world']
    getListOfFolderNames('\\hello\\world\\'); // ['hello', 'world']

    Parameters

    • path: string

    Returns string[]

    the path segments

  • removeFileExtension(fileName: string): string
  • Removes the file extension if exists

    example
    removeFileExtension('test.ext'); // test
    removeFileExtension('test.ext.doc'); // test.ext
    removeFileExtension('test'); // test

    Parameters

    • fileName: string

    Returns string

    file name without extension

  • sanitizeFileName(fileName: string): string
  • Replaces '' with '_' or 'File Name' if empty

    example
    sanitizeFileName(' | \\ trimBetweenSpecial \\ | '); // '| _ trimBetweenSpecial _ |'
    sanitizeFileName('fake/folder/name\\'); // 'fake/folder/name_'
    sanitizeFileName(' '); // 'File Name'

    Parameters

    • fileName: string

    Returns string

    sanitized file name supported by laserfiche repository

Generated using TypeDoc