• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ringcentral / ringcentral-js-widgets / 5607299609

pending completion
5607299609

push

github

web-flow
sync features and bugfixs from dd3f20d7 (#1730)

8800 of 15728 branches covered (55.95%)

Branch coverage included in aggregate %.

881 of 1290 new or added lines in 248 files covered. (68.29%)

13 existing lines in 7 files now uncovered.

14708 of 22609 relevant lines covered (65.05%)

142084.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.22
/packages/utils/src/utils/fileHandler/fileHandler.ts
1
import {
2
  CONTENT_TYPE_TO_EXTENSION,
3
  EXTENSION_TO_CONTENT_TYPE,
4
} from './constant';
5

6
/**
7
 * get file name with extension.
8
 */
9
export function getFilename(fullPath: string) {
NEW
10
  return fullPath.substring(fullPath.lastIndexOf('/') + 1);
×
11
}
12

13
/**
14
 * remove file path extension.
15
 */
16
export const removeExtension = (str: string) => {
228✔
NEW
17
  return str.split('.').slice(0, -1).join('.');
×
18
};
19

20
/**
21
 * get file extension.
22
 */
23
export const getFileExtension = (fileName: string) => {
228✔
NEW
24
  const splitArrays = fileName.toLowerCase().split('.');
×
NEW
25
  return splitArrays.length > 1 ? splitArrays.pop()! : '';
×
26
};
27

28
/**
29
 * get file extension from content type
30
 *
31
 * @example
32
 * ```ts
33
 * console.log(getFileExtensionFromContentType('image/gif')) // gif
34
 * ```
35
 */
36
export const getFileExtensionFromContentType = (contentType?: string) => {
228✔
NEW
37
  return contentType
×
38
    ? CONTENT_TYPE_TO_EXTENSION[contentType.toLowerCase()] ??
×
39
        contentType.split('/')[1]
40
    : undefined;
41
};
42

43
/**
44
 * get content type from file extension
45
 *
46
 * @example
47
 * ```ts
48
 * console.log(getFileContentTypeFromExtension('gif')) // image/gif
49
 * ```
50
 */
51
export const getFileContentTypeFromExtension = (extensionName?: string) => {
228✔
NEW
52
  return extensionName
×
53
    ? EXTENSION_TO_CONTENT_TYPE[extensionName.toLowerCase()]
54
    : undefined;
55
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc