diff options
| author | Caleb Mabry <caleb.mabry.15@cnu.edu> | 2022-07-15 00:44:10 -0400 |
|---|---|---|
| committer | Caleb Mabry <caleb.mabry.15@cnu.edu> | 2022-07-15 00:44:10 -0400 |
| commit | a46ccf72cef30eccf4cb3f9cdea9c461bb44f8b2 (patch) | |
| tree | da26780cb62e56150f4695561f8ced2c499f02f2 /webAO | |
| parent | 9ac75a06cd792074eaf7b3fbf3a1e5c482be60ac (diff) | |
Resolving issue with name display and encoding issue
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.ts | 9 | ||||
| -rw-r--r-- | webAO/utils/__tests__/paths.test.ts | 13 | ||||
| -rw-r--r-- | webAO/utils/paths.ts | 1 |
3 files changed, 20 insertions, 3 deletions
diff --git a/webAO/client.ts b/webAO/client.ts index 2af1ab9..99462cd 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -8,7 +8,7 @@ import FingerprintJS from '@fingerprintjs/fingerprintjs'; import { EventEmitter } from 'events'; import tryUrls from './utils/tryUrls' import { - escapeChat, prepChat, safeTags, + escapeChat, prepChat, safeTags, unescapeChat, } from './encoding'; import mlConfig from './utils/aoml'; // Load some defaults for the background and evidence dropdowns @@ -30,6 +30,7 @@ import getAnimLength from './utils/getAnimLength.js'; import getResources from './utils/getResources.js'; import transparentPng from './constants/transparentPng'; import downloadFile from './services/downloadFile' +import { getFilenameFromPath } from './utils/paths'; const version = process.env.npm_package_version; let client: Client; @@ -1180,7 +1181,9 @@ class Client extends EventEmitter { addTrack(trackname: string) { const newentry = <HTMLOptionElement>document.createElement('OPTION'); - newentry.text = trackname; + const songName = getFilenameFromPath(trackname); + newentry.text = unescapeChat(songName); + newentry.value = trackname; (<HTMLSelectElement>document.getElementById('client_musiclist')).options.add(newentry); this.musics.push(trackname); } @@ -1271,7 +1274,7 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time - const trackname = safeTags(args[i]); + const trackname = args[i]; const trackindex = i - 1; document.getElementById('client_loadingtext').innerHTML = `Loading Music ${i}/${this.music_list_length}`; (<HTMLProgressElement>document.getElementById('client_loadingbar')).value = this.char_list_length + this.evidence_list_length + i; diff --git a/webAO/utils/__tests__/paths.test.ts b/webAO/utils/__tests__/paths.test.ts new file mode 100644 index 0000000..4f41d09 --- /dev/null +++ b/webAO/utils/__tests__/paths.test.ts @@ -0,0 +1,13 @@ +import {getFilenameFromPath} from '../paths' +jest.mock('../fileExists') + +describe('getFilenameFromPath', () => { + const EXAMPLE_PATH = "localhost/stoneddiscord/assets.png" + it('Should get the last value from a path', async () => { + const actual = getFilenameFromPath(EXAMPLE_PATH); + const expected = 'assets.png'; + expect(actual).toBe(expected); + }); +}) + + diff --git a/webAO/utils/paths.ts b/webAO/utils/paths.ts new file mode 100644 index 0000000..f4284b6 --- /dev/null +++ b/webAO/utils/paths.ts @@ -0,0 +1 @@ +export const getFilenameFromPath = (path: string) => path.substring(path.lastIndexOf('/') + 1) |
