Skip to content

Commit

Permalink
remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Oct 12, 2023
1 parent 5b1f8bd commit 1393e2d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
2 changes: 1 addition & 1 deletion src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LayoutTemplate, SerialLayoutTemplate } from '@app/Dashboard/types';
import { RecordingLabel } from '@app/RecordingMetadata/types';
import { createBlobURL, jvmIdToSubdirectoryName } from '@app/utils/utils';
import { createBlobURL } from '@app/utils/utils';
import { ValidatedOptions } from '@patternfly/react-core';
import _ from 'lodash';
import { EMPTY, forkJoin, from, Observable, ObservableInput, of, ReplaySubject, shareReplay, throwError } from 'rxjs';
Expand Down
37 changes: 0 additions & 37 deletions src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,42 +248,5 @@ export const isAssetNew = (currVer: string) => {
return !semverValid(oldVer) || semverGt(currVer, oldVer);
};

export const utf8ToBase32 = (str: string): string => {
const encoder = new TextEncoder();
const byteArray = encoder.encode(str);
const BASE32_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
let bits = 0;
let value = 0;
let base32 = '';

for (let i = 0; i < byteArray.length; i++) {
value = (value << 8) | byteArray[i];
bits += 8;
while (bits >= 5) {
bits -= 5;
base32 += BASE32_ALPHABET[(value >>> bits) & 0x1f];
}
}

if (bits > 0) {
value <<= 5 - bits;
base32 += BASE32_ALPHABET[value & 0x1f];
}

const paddingLength = base32.length % 8 !== 0 ? 8 - (base32.length % 8) : 0;
for (let i = 0; i < paddingLength; i++) {
base32 += '=';
}

return base32;
};

export const jvmIdToSubdirectoryName = (jvmId: string): string => {
if (jvmId === UPLOADS_SUBDIRECTORY || jvmId === 'lost') {
return jvmId;
}
return utf8ToBase32(jvmId);
};

export const includesSubstr = (a: string, b: string): boolean =>
!!a && !!b && a.toLowerCase().includes(b.trim().toLowerCase());

0 comments on commit 1393e2d

Please sign in to comment.