(id: string)
| 70 | const invalidUrlPathCharRE = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g |
| 71 | const replaceNestedIdRE = /\s*>\s*/g |
| 72 | export const flattenId = (id: string): string => { |
| 73 | const flatId = limitFlattenIdLength( |
| 74 | id |
| 75 | .replaceAll(/_+/g, '$&__') |
| 76 | .replaceAll('/', '_') |
| 77 | .replaceAll('.', '__') |
| 78 | .replace(replaceNestedIdRE, '_n_') |
| 79 | // replace any characters that will be replaced by sanitizeFileName |
| 80 | .replace( |
| 81 | invalidUrlPathCharRE, |
| 82 | (c) => '_0' + c.charCodeAt(0).toString(16) + '_', |
| 83 | ), |
| 84 | ) |
| 85 | return flatId |
| 86 | } |
| 87 | |
| 88 | const FLATTEN_ID_HASH_LENGTH = 8 |
| 89 | const FLATTEN_ID_MAX_FILE_LENGTH = 170 |
no test coverage detected