diff options
| author | stonedDiscord <stonedDiscord@users.noreply.github.com> | 2024-11-20 13:31:50 +0000 |
|---|---|---|
| committer | GitHub Action <actions@github.com> | 2024-11-20 13:31:50 +0000 |
| commit | 6684f3fce6e90fd0574d7bab63b629554ab03ef6 (patch) | |
| tree | b2a62247d17e23a77af57aea355ba621666817c2 /webAO/utils | |
| parent | 95a2d1361d84c61b454ebe506e6963b93f6d8dee (diff) | |
Prettified Code!
Diffstat (limited to 'webAO/utils')
| -rw-r--r-- | webAO/utils/__tests__/aoml.test.ts | 152 | ||||
| -rw-r--r-- | webAO/utils/__tests__/paths.test.ts | 22 | ||||
| -rw-r--r-- | webAO/utils/__tests__/tryUrls.test.ts | 51 | ||||
| -rw-r--r-- | webAO/utils/aoml.ts | 209 | ||||
| -rw-r--r-- | webAO/utils/fileExists.ts | 34 | ||||
| -rw-r--r-- | webAO/utils/filesExist.ts | 32 | ||||
| -rw-r--r-- | webAO/utils/findImgSrc.ts | 16 | ||||
| -rw-r--r-- | webAO/utils/getCookie.ts | 32 | ||||
| -rw-r--r-- | webAO/utils/paths.ts | 3 | ||||
| -rw-r--r-- | webAO/utils/queryParser.ts | 34 | ||||
| -rw-r--r-- | webAO/utils/setCookie.ts | 2 | ||||
| -rw-r--r-- | webAO/utils/tryUrls.ts | 31 |
12 files changed, 303 insertions, 315 deletions
diff --git a/webAO/utils/__tests__/aoml.test.ts b/webAO/utils/__tests__/aoml.test.ts index 78355ed..b5cd9b1 100644 --- a/webAO/utils/__tests__/aoml.test.ts +++ b/webAO/utils/__tests__/aoml.test.ts @@ -1,7 +1,7 @@ -import request from '../../services/request' -import mlConfig from '../aoml'; +import request from "../../services/request"; +import mlConfig from "../aoml"; -jest.mock('../../services/request') +jest.mock("../../services/request"); const networkRequest = ` c0 = 247, 247, 247 c0_name = White @@ -34,80 +34,76 @@ c6_start = | c6_end = | c6_remove = 0 c6_talking = 0 -` +`; const mockRequest = request as jest.MockedFunction<typeof request>; -mockRequest.mockReturnValue(Promise.resolve(networkRequest)) - -describe('mlConfig', () => { - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); - - }); - - it('Should make a network request', () => { - mlConfig('localhost') - expect(mockRequest).toHaveBeenCalledTimes(1); - }); -}) -describe('applyMarkdown', () => { - const config = mlConfig('localhost') - - beforeEach(() => { - // Clear all instances and calls to constructor and all methods: - mockRequest.mockClear(); - - }); - - it('Should create an array of spans containing letters', async () => { - const word = `hello` - const actual = await config.applyMarkdown(`hello`, `blue`) - let index = 0 - for (const element of actual) { - expect(element.innerHTML).toBe(word[index]) - index++ - } - }) - it('Should add colors based on settings', async () => { - const config = mlConfig('localhost') - const actual = await config.applyMarkdown(`(heya)`, `blue`) - expect(actual[0].getAttribute('style')).toBe('color: rgb(107, 198, 247);') - }) - it('Should keep a letter if remove = 0', async () => { - const config = mlConfig('localhost') - - const actual = await config.applyMarkdown(`(What())Hey!`, `white`) - const expected = `(` - expect(actual[5].innerHTML).toBe(expected) - }) - it('Should remove a letter if remove = 1', async () => { - const config = mlConfig('localhost') - - const actual = await config.applyMarkdown(`~What~()Hey!`, `white`) - const expected = `` - expect(actual[0].innerHTML).toBe(expected) - }) - it('Should remove a letter if remove = 1', async () => { - const config = mlConfig('localhost') - - const actual = await config.applyMarkdown(`~What~()Hey!`, `white`) - const expected = `` - expect(actual[0].innerHTML).toBe(expected) - }) - it('Should keep a closing letter if remove = 0', async () => { - const config = mlConfig('localhost') - - const actual = await config.applyMarkdown(`~NO[]~!`, `white`) - const expected = `` - expect(actual[4].innerHTML).toBe(expected) - }) - it('Should remove a closing letter if remove = 1', async () => { - const config = mlConfig('localhost') - const actual = await config.applyMarkdown(`~NO||~!`, `white`) - const expected = `` - expect(actual[5].innerHTML).toBe(expected) - }) - -}) - +mockRequest.mockReturnValue(Promise.resolve(networkRequest)); + +describe("mlConfig", () => { + beforeEach(() => { + // Clear all instances and calls to constructor and all methods: + mockRequest.mockClear(); + }); + + it("Should make a network request", () => { + mlConfig("localhost"); + expect(mockRequest).toHaveBeenCalledTimes(1); + }); +}); +describe("applyMarkdown", () => { + const config = mlConfig("localhost"); + + beforeEach(() => { + // Clear all instances and calls to constructor and all methods: + mockRequest.mockClear(); + }); + + it("Should create an array of spans containing letters", async () => { + const word = `hello`; + const actual = await config.applyMarkdown(`hello`, `blue`); + let index = 0; + for (const element of actual) { + expect(element.innerHTML).toBe(word[index]); + index++; + } + }); + it("Should add colors based on settings", async () => { + const config = mlConfig("localhost"); + const actual = await config.applyMarkdown(`(heya)`, `blue`); + expect(actual[0].getAttribute("style")).toBe("color: rgb(107, 198, 247);"); + }); + it("Should keep a letter if remove = 0", async () => { + const config = mlConfig("localhost"); + + const actual = await config.applyMarkdown(`(What())Hey!`, `white`); + const expected = `(`; + expect(actual[5].innerHTML).toBe(expected); + }); + it("Should remove a letter if remove = 1", async () => { + const config = mlConfig("localhost"); + + const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); + const expected = ``; + expect(actual[0].innerHTML).toBe(expected); + }); + it("Should remove a letter if remove = 1", async () => { + const config = mlConfig("localhost"); + + const actual = await config.applyMarkdown(`~What~()Hey!`, `white`); + const expected = ``; + expect(actual[0].innerHTML).toBe(expected); + }); + it("Should keep a closing letter if remove = 0", async () => { + const config = mlConfig("localhost"); + + const actual = await config.applyMarkdown(`~NO[]~!`, `white`); + const expected = ``; + expect(actual[4].innerHTML).toBe(expected); + }); + it("Should remove a closing letter if remove = 1", async () => { + const config = mlConfig("localhost"); + const actual = await config.applyMarkdown(`~NO||~!`, `white`); + const expected = ``; + expect(actual[5].innerHTML).toBe(expected); + }); +}); diff --git a/webAO/utils/__tests__/paths.test.ts b/webAO/utils/__tests__/paths.test.ts index 4f41d09..fe7b1bf 100644 --- a/webAO/utils/__tests__/paths.test.ts +++ b/webAO/utils/__tests__/paths.test.ts @@ -1,13 +1,11 @@ -import {getFilenameFromPath} from '../paths' -jest.mock('../fileExists') +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); - }); -}) - - +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/__tests__/tryUrls.test.ts b/webAO/utils/__tests__/tryUrls.test.ts index ebc2f6b..f85392c 100644 --- a/webAO/utils/__tests__/tryUrls.test.ts +++ b/webAO/utils/__tests__/tryUrls.test.ts @@ -1,31 +1,28 @@ -import fileExists from '../fileExists' -import tryUrls from '../tryUrls'; -import transparentPng from '../../constants/transparentPng' -jest.mock('../fileExists') +import fileExists from "../fileExists"; +import tryUrls from "../tryUrls"; +import transparentPng from "../../constants/transparentPng"; +jest.mock("../fileExists"); const mockFileExists = fileExists as jest.MockedFunction<typeof fileExists>; -describe('tryUrls', () => { - it('Should try multiple file extensions', async () => { - const url = "localhost/stoneddiscord/assets" - mockFileExists - .mockReturnValueOnce(Promise.resolve(false)) - .mockReturnValueOnce(Promise.resolve(false)) - .mockReturnValueOnce(Promise.resolve(false)) - .mockReturnValueOnce(Promise.resolve(true)) - const actual = await tryUrls(url) - const expected = 'localhost/stoneddiscord/assets.apng' - expect(actual).toBe(expected); - }); - - it('Should return a transparent png if it cant find any assets', async () => { - const url = "localhost/stoneddiscord/assets" - mockFileExists - .mockReturnValue(Promise.resolve(false)) - const actual = await tryUrls(url) - const expected = transparentPng - expect(actual).toBe(expected); - }); -}) - +describe("tryUrls", () => { + it("Should try multiple file extensions", async () => { + const url = "localhost/stoneddiscord/assets"; + mockFileExists + .mockReturnValueOnce(Promise.resolve(false)) + .mockReturnValueOnce(Promise.resolve(false)) + .mockReturnValueOnce(Promise.resolve(false)) + .mockReturnValueOnce(Promise.resolve(true)); + const actual = await tryUrls(url); + const expected = "localhost/stoneddiscord/assets.apng"; + expect(actual).toBe(expected); + }); + it("Should return a transparent png if it cant find any assets", async () => { + const url = "localhost/stoneddiscord/assets"; + mockFileExists.mockReturnValue(Promise.resolve(false)); + const actual = await tryUrls(url); + const expected = transparentPng; + expect(actual).toBe(expected); + }); +}); diff --git a/webAO/utils/aoml.ts b/webAO/utils/aoml.ts index a2c1dd5..f4a6da5 100644 --- a/webAO/utils/aoml.ts +++ b/webAO/utils/aoml.ts @@ -1,118 +1,117 @@ -import request from "../services/request" +import request from "../services/request"; interface Aoml { - [key: string]: string | number, - name: string; - start: string; - end: string; - remove: number; - talking: number; - color: string; + [key: string]: string | number; + name: string; + start: string; + end: string; + remove: number; + talking: number; + color: string; } const aomlParser = (text: string) => { - const parsed: {[key: string]: Aoml}= {} - let currentHeader = '' - for (const line of text.split(/\r?\n/)) { - if (line === '') { - currentHeader = '' - continue; - } - const content = line.split(' = ') - const contentName = content[0] - const contentValue = content[1] - if (currentHeader === '') { - currentHeader = contentName - parsed[currentHeader] = { - color: contentValue - } as Aoml - } else { - const contentKey = contentName.split('_')[1] - parsed[currentHeader][contentKey] = contentValue - } + const parsed: { [key: string]: Aoml } = {}; + let currentHeader = ""; + for (const line of text.split(/\r?\n/)) { + if (line === "") { + currentHeader = ""; + continue; } - return parsed -} + const content = line.split(" = "); + const contentName = content[0]; + const contentValue = content[1]; + if (currentHeader === "") { + currentHeader = contentName; + parsed[currentHeader] = { + color: contentValue, + } as Aoml; + } else { + const contentKey = contentName.split("_")[1]; + parsed[currentHeader][contentKey] = contentValue; + } + } + return parsed; +}; const mlConfig = (AO_HOST: string) => { - const defaultUrl = `${AO_HOST}themes/default/chat_config.ini` - const aomlParsed: Promise<{ [key: string]: Aoml }> = request(defaultUrl).then((data) => aomlParser(data)); - - + const defaultUrl = `${AO_HOST}themes/default/chat_config.ini`; + const aomlParsed: Promise<{ [key: string]: Aoml }> = request(defaultUrl).then( + (data) => aomlParser(data), + ); - const createIdentifiers = async () => { - const identifiers = new Map<string, Aoml>() - for (const [ruleName, value] of Object.entries(await aomlParsed)) { - if (value.start && value.end) { - identifiers.set(value.start, value) - identifiers.set(value.end, value) - } - } - return identifiers + const createIdentifiers = async () => { + const identifiers = new Map<string, Aoml>(); + for (const [ruleName, value] of Object.entries(await aomlParsed)) { + if (value.start && value.end) { + identifiers.set(value.start, value); + identifiers.set(value.end, value); + } } - const createStartIdentifiers = async () => { - const startingIdentifiers = new Set<string>() - for (const [ruleName, value] of Object.entries(await aomlParsed)) { - if (value?.start && value?.end) { - startingIdentifiers.add(value.start) - } - } - return startingIdentifiers + return identifiers; + }; + const createStartIdentifiers = async () => { + const startingIdentifiers = new Set<string>(); + for (const [ruleName, value] of Object.entries(await aomlParsed)) { + if (value?.start && value?.end) { + startingIdentifiers.add(value.start); + } } - const applyMarkdown = async (text: string, defaultColor: string) => { - const identifiers = await createIdentifiers() - const startIdentifiers = await createStartIdentifiers() - const closingStack = [] - const colorStack = [] - // each value in output will be an html element - const output: HTMLSpanElement[] = [] - for (const letter of text) { - const currentSelector = document.createElement('span') - const currentIdentifier = identifiers.get(letter) - const currentClosingLetter = closingStack[closingStack.length - 1] - const keepChar = Number(currentIdentifier?.remove) === 0 - if (currentClosingLetter === letter) { - const r = colorStack[colorStack.length - 1][0] - const g = colorStack[colorStack.length - 1][1] - const b = colorStack[colorStack.length - 1][2] - const currentColor = `color: rgb(${r},${g},${b});` - currentSelector.setAttribute('style', currentColor) - closingStack.pop() - colorStack.pop() - if (keepChar) { - currentSelector.innerHTML = letter - } - } - else if (startIdentifiers.has(letter)) { - const color = identifiers.get(letter).color.split(',') - const r = color[0] - const g = color[1] - const b = color[2] - colorStack.push([r, g, b]) - closingStack.push(currentIdentifier.end) - const currentColor = `color: rgb(${r},${g},${b});` - currentSelector.setAttribute('style', currentColor) - if (keepChar) { - currentSelector.innerHTML = letter - } - } else { - currentSelector.innerHTML = letter - if (colorStack.length === 0) { - currentSelector.className = `text_${defaultColor}` - } else { - const r = colorStack[colorStack.length - 1][0] - const g = colorStack[colorStack.length - 1][1] - const b = colorStack[colorStack.length - 1][2] - const currentColor = `color: rgb(${r},${g},${b});` - currentSelector.setAttribute('style', currentColor) - } - } - output.push(currentSelector) + return startingIdentifiers; + }; + const applyMarkdown = async (text: string, defaultColor: string) => { + const identifiers = await createIdentifiers(); + const startIdentifiers = await createStartIdentifiers(); + const closingStack = []; + const colorStack = []; + // each value in output will be an html element + const output: HTMLSpanElement[] = []; + for (const letter of text) { + const currentSelector = document.createElement("span"); + const currentIdentifier = identifiers.get(letter); + const currentClosingLetter = closingStack[closingStack.length - 1]; + const keepChar = Number(currentIdentifier?.remove) === 0; + if (currentClosingLetter === letter) { + const r = colorStack[colorStack.length - 1][0]; + const g = colorStack[colorStack.length - 1][1]; + const b = colorStack[colorStack.length - 1][2]; + const currentColor = `color: rgb(${r},${g},${b});`; + currentSelector.setAttribute("style", currentColor); + closingStack.pop(); + colorStack.pop(); + if (keepChar) { + currentSelector.innerHTML = letter; } - return output - } - return { - applyMarkdown + } else if (startIdentifiers.has(letter)) { + const color = identifiers.get(letter).color.split(","); + const r = color[0]; + const g = color[1]; + const b = color[2]; + colorStack.push([r, g, b]); + closingStack.push(currentIdentifier.end); + const currentColor = `color: rgb(${r},${g},${b});`; + currentSelector.setAttribute("style", currentColor); + if (keepChar) { + currentSelector.innerHTML = letter; + } + } else { + currentSelector.innerHTML = letter; + if (colorStack.length === 0) { + currentSelector.className = `text_${defaultColor}`; + } else { + const r = colorStack[colorStack.length - 1][0]; + const g = colorStack[colorStack.length - 1][1]; + const b = colorStack[colorStack.length - 1][2]; + const currentColor = `color: rgb(${r},${g},${b});`; + currentSelector.setAttribute("style", currentColor); + } + } + output.push(currentSelector); } -} + return output; + }; + return { + applyMarkdown, + }; +}; -export default mlConfig
\ No newline at end of file +export default mlConfig; diff --git a/webAO/utils/fileExists.ts b/webAO/utils/fileExists.ts index abb2928..1dceb72 100644 --- a/webAO/utils/fileExists.ts +++ b/webAO/utils/fileExists.ts @@ -1,19 +1,19 @@ export default async function fileExists(url: string): Promise<boolean> { - return new Promise((resolve) => { - const xhr = new XMLHttpRequest(); - xhr.open('HEAD', url); - xhr.onload = function checkLoad() { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - resolve(true); - } else { - resolve(false); - } - } - }; - xhr.onerror = function checkError() { - resolve(false); - }; - xhr.send(null); - }); + return new Promise((resolve) => { + const xhr = new XMLHttpRequest(); + xhr.open("HEAD", url); + xhr.onload = function checkLoad() { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + resolve(true); + } else { + resolve(false); + } + } + }; + xhr.onerror = function checkError() { + resolve(false); + }; + xhr.send(null); + }); } diff --git a/webAO/utils/filesExist.ts b/webAO/utils/filesExist.ts index 2f39427..c41cb2f 100644 --- a/webAO/utils/filesExist.ts +++ b/webAO/utils/filesExist.ts @@ -6,23 +6,25 @@ import fileExists from "./fileExists"; * @param urls the list of URLs to check * @returns either the first URL that exists or null if none were found */ -export default async function filesExist(urls: string[]): Promise<string | null> { - const promises = urls.map(async (url) => { - if (await fileExists(url)) { - return url; - } - return null; - }); +export default async function filesExist( + urls: string[], +): Promise<string | null> { + const promises = urls.map(async (url) => { + if (await fileExists(url)) { + return url; + } + return null; + }); - // Run all in parallel - const results = await Promise.all(promises); + // Run all in parallel + const results = await Promise.all(promises); - // Find the first URL that exists (not null) or return null if none exist - for (const result of results) { - if (result !== null) { - return result; - } + // Find the first URL that exists (not null) or return null if none exist + for (const result of results) { + if (result !== null) { + return result; } + } - return null; // None of the URLs exist + return null; // None of the URLs exist } diff --git a/webAO/utils/findImgSrc.ts b/webAO/utils/findImgSrc.ts index b4db849..d33215a 100644 --- a/webAO/utils/findImgSrc.ts +++ b/webAO/utils/findImgSrc.ts @@ -1,5 +1,5 @@ import filesExist from "./filesExist"; -import transparentPng from '../constants/transparentPng' +import transparentPng from "../constants/transparentPng"; /** * This function takes a list of urls and returns the first one that exists. @@ -9,11 +9,11 @@ import transparentPng from '../constants/transparentPng' * @returns The image source of the first url that exists, or a transparent png if none exist */ export default async function findImgSrc(urls: string[]): Promise<string> { - return filesExist(urls).then((url) => { - if (url !== null) { - return url; - } - // If none of the images exist, return a transparent png - return transparentPng; - }); + return filesExist(urls).then((url) => { + if (url !== null) { + return url; + } + // If none of the images exist, return a transparent png + return transparentPng; + }); } diff --git a/webAO/utils/getCookie.ts b/webAO/utils/getCookie.ts index 638dcb7..7373688 100644 --- a/webAO/utils/getCookie.ts +++ b/webAO/utils/getCookie.ts @@ -5,22 +5,22 @@ * @param {string} cname The name of the cookie to return */ const getCookie = (cname: string) => { - try { - const name = `${cname}=`; - const decodedCookie = decodeURIComponent(document.cookie); - const ca = decodedCookie.split(';'); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) === ' ') { - c = c.substring(1); - } - if (c.indexOf(name) === 0) { - return c.substring(name.length, c.length); - } - } - return ''; - } catch (error) { - return ''; + try { + const name = `${cname}=`; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(";"); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === " ") { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } } + return ""; + } catch (error) { + return ""; + } }; export default getCookie; diff --git a/webAO/utils/paths.ts b/webAO/utils/paths.ts index f4284b6..8c0d007 100644 --- a/webAO/utils/paths.ts +++ b/webAO/utils/paths.ts @@ -1 +1,2 @@ -export const getFilenameFromPath = (path: string) => path.substring(path.lastIndexOf('/') + 1) +export const getFilenameFromPath = (path: string) => + path.substring(path.lastIndexOf("/") + 1); diff --git a/webAO/utils/queryParser.ts b/webAO/utils/queryParser.ts index 1a3cea6..5263f6e 100644 --- a/webAO/utils/queryParser.ts +++ b/webAO/utils/queryParser.ts @@ -1,25 +1,25 @@ /* eslint @typescript-eslint/no-explicit-any: "warn" */ interface QueryParams { - ip: string; - connect: string; - mode: string; - asset: string; - theme: string; - serverName: string; + ip: string; + connect: string; + mode: string; + asset: string; + theme: string; + serverName: string; } const queryParser = (): QueryParams => { - const protocol = window.location.protocol; - const urlParams = new URLSearchParams(window.location.search); - const queryParams = { - ip: urlParams.get("ip") || "", - connect: urlParams.get("connect") || "", - mode: urlParams.get("mode") || "join", - asset: urlParams.get("asset") || `${protocol}//attorneyoffline.de/base/`, - theme: urlParams.get("theme") || "default", - serverName: urlParams.get("serverName") || "Attorney Online session", - } - return queryParams as QueryParams; + const protocol = window.location.protocol; + const urlParams = new URLSearchParams(window.location.search); + const queryParams = { + ip: urlParams.get("ip") || "", + connect: urlParams.get("connect") || "", + mode: urlParams.get("mode") || "join", + asset: urlParams.get("asset") || `${protocol}//attorneyoffline.de/base/`, + theme: urlParams.get("theme") || "default", + serverName: urlParams.get("serverName") || "Attorney Online session", + }; + return queryParams as QueryParams; }; export default queryParser; diff --git a/webAO/utils/setCookie.ts b/webAO/utils/setCookie.ts index a4e554e..421fe81 100644 --- a/webAO/utils/setCookie.ts +++ b/webAO/utils/setCookie.ts @@ -7,6 +7,6 @@ * @param {any} value The value of that cookie option */ const setCookie = (cname: string, value: any) => { - document.cookie = `${cname}=${value};SameSite=Strict`; + document.cookie = `${cname}=${value};SameSite=Strict`; }; export default setCookie; diff --git a/webAO/utils/tryUrls.ts b/webAO/utils/tryUrls.ts index 14ef885..127bc5b 100644 --- a/webAO/utils/tryUrls.ts +++ b/webAO/utils/tryUrls.ts @@ -1,20 +1,15 @@ -import fileExists from './fileExists' -import transparentPng from '../constants/transparentPng' -const urlExtensionsToTry = [ - '.png', - '.gif', - '.webp', - '.apng' -] +import fileExists from "./fileExists"; +import transparentPng from "../constants/transparentPng"; +const urlExtensionsToTry = [".png", ".gif", ".webp", ".apng"]; const tryUrls = async (url: string) => { - for (let i = 0; i < urlExtensionsToTry.length; i++) { - const extension = urlExtensionsToTry[i] - const fullFileUrl = url + extension - const exists = await fileExists(fullFileUrl); - if (exists) { - return fullFileUrl - } + for (let i = 0; i < urlExtensionsToTry.length; i++) { + const extension = urlExtensionsToTry[i]; + const fullFileUrl = url + extension; + const exists = await fileExists(fullFileUrl); + if (exists) { + return fullFileUrl; } - return transparentPng -} -export default tryUrls
\ No newline at end of file + } + return transparentPng; +}; +export default tryUrls; |
