diff --git a/src/tools/email-normalizer/email-normalizer.vue b/src/tools/email-normalizer/email-normalizer.vue
deleted file mode 100644
index eae97c4e..00000000
--- a/src/tools/email-normalizer/email-normalizer.vue
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
diff --git a/src/tools/email-normalizer/index.ts b/src/tools/email-normalizer/index.ts
deleted file mode 100644
index 299a30f7..00000000
--- a/src/tools/email-normalizer/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Mail } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'Email normalizer',
- path: '/email-normalizer',
- description: 'Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning.',
- keywords: ['email', 'normalizer'],
- component: () => import('./email-normalizer.vue'),
- icon: Mail,
- createdAt: new Date('2024-08-15'),
-});
diff --git a/src/tools/emoji-picker/emoji-picker.vue b/src/tools/emoji-picker/emoji-picker.vue
index a12b10c2..750695f5 100644
--- a/src/tools/emoji-picker/emoji-picker.vue
+++ b/src/tools/emoji-picker/emoji-picker.vue
@@ -4,7 +4,6 @@ import emojiKeywords from 'emojilib';
import _ from 'lodash';
import type { EmojiInfo } from './emoji.types';
import { useFuzzySearch } from '@/composable/fuzzySearch';
-import useDebouncedRef from '@/composable/debouncedref';
const escapeUnicode = ({ emoji }: { emoji: string }) => emoji.split('').map(unit => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
const getEmojiCodePoints = ({ emoji }: { emoji: string }) => emoji.codePointAt(0) ? `0x${emoji.codePointAt(0)?.toString(16)}` : undefined;
@@ -24,7 +23,7 @@ const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _
.map((emojiInfos, group) => ({ group, emojiInfos }))
.value();
-const searchQuery = useDebouncedRef('', 500);
+const searchQuery = ref('');
const { searchResult } = useFuzzySearch({
search: searchQuery,
diff --git a/src/tools/html-wysiwyg-editor/editor/menu-bar.vue b/src/tools/html-wysiwyg-editor/editor/menu-bar.vue
index 9069673c..d3ad3168 100644
--- a/src/tools/html-wysiwyg-editor/editor/menu-bar.vue
+++ b/src/tools/html-wysiwyg-editor/editor/menu-bar.vue
@@ -84,8 +84,8 @@ const items: MenuItem[] = [
type: 'button',
icon: H3,
title: 'Heading 3',
- action: () => editor.value.chain().focus().toggleHeading({ level: 3 }).run(),
- isActive: () => editor.value.isActive('heading', { level: 3 }),
+ action: () => editor.value.chain().focus().toggleHeading({ level: 4 }).run(),
+ isActive: () => editor.value.isActive('heading', { level: 4 }),
},
{
type: 'button',
diff --git a/src/tools/index.ts b/src/tools/index.ts
index 388cfaf4..aa861c93 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -1,17 +1,11 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
-import { tool as emailNormalizer } from './email-normalizer';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
-import { tool as xmlToJson } from './xml-to-json';
-import { tool as jsonToXml } from './json-to-xml';
-import { tool as regexTester } from './regex-tester';
-import { tool as regexMemo } from './regex-memo';
-import { tool as markdownToHtml } from './markdown-to-html';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -113,9 +107,6 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
- xmlToJson,
- jsonToXml,
- markdownToHtml,
],
},
{
@@ -157,9 +148,6 @@ export const toolsByCategory: ToolCategory[] = [
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer,
- emailNormalizer,
- regexTester,
- regexMemo,
],
},
{
diff --git a/src/tools/json-to-xml/index.ts b/src/tools/json-to-xml/index.ts
deleted file mode 100644
index c35ace2b..00000000
--- a/src/tools/json-to-xml/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Braces } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'JSON to XML',
- path: '/json-to-xml',
- description: 'Convert JSON to XML',
- keywords: ['json', 'xml'],
- component: () => import('./json-to-xml.vue'),
- icon: Braces,
- createdAt: new Date('2024-08-09'),
-});
diff --git a/src/tools/json-to-xml/json-to-xml.vue b/src/tools/json-to-xml/json-to-xml.vue
deleted file mode 100644
index 96a7cf16..00000000
--- a/src/tools/json-to-xml/json-to-xml.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
diff --git a/src/tools/jwt-parser/jwt-parser.vue b/src/tools/jwt-parser/jwt-parser.vue
index a26064d7..6b30fc0c 100644
--- a/src/tools/jwt-parser/jwt-parser.vue
+++ b/src/tools/jwt-parser/jwt-parser.vue
@@ -39,7 +39,7 @@ const validation = useValidation({
{{ section.title }}
-
+ |
{{ claim }}
@@ -47,7 +47,7 @@ const validation = useValidation({
({{ claimDescription }})
|
-
+ |
{{ value }}
({{ friendlyValue }})
diff --git a/src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue b/src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue
index ccd8b519..9085725f 100644
--- a/src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue
+++ b/src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue
@@ -2,7 +2,6 @@
import { generateLoremIpsum } from './lorem-ipsum-generator.service';
import { useCopy } from '@/composable/copy';
import { randIntFromInterval } from '@/utils/random';
-import { computedRefreshable } from '@/composable/computedRefreshable';
const paragraphs = ref(1);
const sentences = ref([3, 8]);
@@ -10,7 +9,7 @@ const words = ref([8, 15]);
const startWithLoremIpsum = ref(true);
const asHTML = ref(false);
-const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
+const loremIpsumText = computed(() =>
generateLoremIpsum({
paragraphCount: paragraphs.value,
asHTML: asHTML.value,
@@ -19,7 +18,6 @@ const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
startWithLoremIpsum: startWithLoremIpsum.value,
}),
);
-
const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to the clipboard' });
@@ -43,13 +41,10 @@ const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to
-
+
Copy
-
- Refresh
-
diff --git a/src/tools/markdown-to-html/index.ts b/src/tools/markdown-to-html/index.ts
deleted file mode 100644
index 73a6cfb3..00000000
--- a/src/tools/markdown-to-html/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Markdown } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'Markdown to HTML',
- path: '/markdown-to-html',
- description: 'Convert Markdown to Html and allow to print (as PDF)',
- keywords: ['markdown', 'html', 'converter', 'pdf'],
- component: () => import('./markdown-to-html.vue'),
- icon: Markdown,
- createdAt: new Date('2024-08-25'),
-});
diff --git a/src/tools/markdown-to-html/markdown-to-html.vue b/src/tools/markdown-to-html/markdown-to-html.vue
deleted file mode 100644
index c84d44ec..00000000
--- a/src/tools/markdown-to-html/markdown-to-html.vue
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Print as PDF
-
-
-
-
diff --git a/src/tools/regex-memo/index.ts b/src/tools/regex-memo/index.ts
deleted file mode 100644
index f1f56489..00000000
--- a/src/tools/regex-memo/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { BrandJavascript } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'Regex cheatsheet',
- path: '/regex-memo',
- description: 'Javascript Regex/Regular Expression cheatsheet',
- keywords: ['regex', 'regular', 'expression', 'javascript', 'memo', 'cheatsheet'],
- component: () => import('./regex-memo.vue'),
- icon: BrandJavascript,
- createdAt: new Date('2024-09-20'),
-});
diff --git a/src/tools/regex-memo/regex-memo.content.md b/src/tools/regex-memo/regex-memo.content.md
deleted file mode 100644
index 0f779401..00000000
--- a/src/tools/regex-memo/regex-memo.content.md
+++ /dev/null
@@ -1,121 +0,0 @@
-### Normal characters
-
-Expression | Description
-:--|:--
-`.` or `[^\n\r]` | any character *excluding* a newline or carriage return
-`[A-Za-z]` | alphabet
-`[a-z]` | lowercase alphabet
-`[A-Z]` | uppercase alphabet
-`\d` or `[0-9]` | digit
-`\D` or `[^0-9]` | non-digit
-`_` | underscore
-`\w` or `[A-Za-z0-9_]` | alphabet, digit or underscore
-`\W` or `[^A-Za-z0-9_]` | inverse of `\w`
-`\S` | inverse of `\s`
-
-### Whitespace characters
-
-Expression | Description
-:--|:--
-` ` | space
-`\t` | tab
-`\n` | newline
-`\r` | carriage return
-`\s` | space, tab, newline or carriage return
-
-### Character set
-
-Expression | Description
-:--|:--
-`[xyz]` | either `x`, `y` or `z`
-`[^xyz]` | neither `x`, `y` nor `z`
-`[1-3]` | either `1`, `2` or `3`
-`[^1-3]` | neither `1`, `2` nor `3`
-
-- Think of a character set as an `OR` operation on the single characters that are enclosed between the square brackets.
-- Use `^` after the opening `[` to “negate” the character set.
-- Within a character set, `.` means a literal period.
-
-### Characters that require escaping
-
-#### Outside a character set
-
-Expression | Description
-:--|:--
-`\.` | period
-`\^` | caret
-`\$` | dollar sign
-`\|` | pipe
-`\\` | back slash
-`\/` | forward slash
-`\(` | opening bracket
-`\)` | closing bracket
-`\[` | opening square bracket
-`\]` | closing square bracket
-`\{` | opening curly bracket
-`\}` | closing curly bracket
-
-#### Inside a character set
-
-Expression | Description
-:--|:--
-`\\` | back slash
-`\]` | closing square bracket
-
-- A `^` must be escaped only if it occurs immediately after the opening `[` of the character set.
-- A `-` must be escaped only if it occurs between two alphabets or two digits.
-
-### Quantifiers
-
-Expression | Description
-:--|:--
-`{2}` | exactly 2
-`{2,}` | at least 2
-`{2,7}` | at least 2 but no more than 7
-`*` | 0 or more
-`+` | 1 or more
-`?` | exactly 0 or 1
-
-- The quantifier goes *after* the expression to be quantified.
-
-### Boundaries
-
-Expression | Description
-:--|:--
-`^` | start of string
-`$` | end of string
-`\b` | word boundary
-
-- How word boundary matching works:
- - At the beginning of the string if the first character is `\w`.
- - Between two adjacent characters within the string, if the first character is `\w` and the second character is `\W`.
- - At the end of the string if the last character is `\w`.
-
-### Matching
-
-Expression | Description
-:--|:--
-`foo\|bar` | match either `foo` or `bar`
-`foo(?=bar)` | match `foo` if it’s before `bar`
-`foo(?!bar)` | match `foo` if it’s *not* before `bar`
-`(?<=bar)foo` | match `foo` if it’s after `bar`
-`(?
-import { useThemeVars } from 'naive-ui';
-import Memo from './regex-memo.content.md';
-
-const themeVars = useThemeVars();
-
-
-
-
-
-
-
-
-
diff --git a/src/tools/regex-tester/index.ts b/src/tools/regex-tester/index.ts
deleted file mode 100644
index 62a5e234..00000000
--- a/src/tools/regex-tester/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Language } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'Regex Tester',
- path: '/regex-tester',
- description: 'Test your regular expressions with sample text.',
- keywords: ['regex', 'tester', 'sample', 'expression'],
- component: () => import('./regex-tester.vue'),
- icon: Language,
- createdAt: new Date('2024-09-20'),
-});
diff --git a/src/tools/regex-tester/regex-tester.service.test.ts b/src/tools/regex-tester/regex-tester.service.test.ts
deleted file mode 100644
index bd4efbbc..00000000
--- a/src/tools/regex-tester/regex-tester.service.test.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { matchRegex } from './regex-tester.service';
-
-const regexesData = [
- {
- regex: '',
- text: '',
- flags: '',
- result: [],
- },
- {
- regex: '.*',
- text: '',
- flags: '',
- result: [],
- },
- {
- regex: '',
- text: 'aaa',
- flags: '',
- result: [],
- },
- {
- regex: 'a',
- text: 'baaa',
- flags: '',
- result: [
- {
- captures: [],
- groups: [],
- index: 1,
- value: 'a',
- },
- ],
- },
- {
- regex: '(.)(? r)',
- text: 'azertyr',
- flags: 'g',
- result: [
- {
- captures: [
- {
- end: 3,
- name: '1',
- start: 2,
- value: 'e',
- },
- {
- end: 4,
- name: '2',
- start: 3,
- value: 'r',
- },
- ],
- groups: [
- {
- end: 4,
- name: 'g',
- start: 3,
- value: 'r',
- },
- ],
- index: 2,
- value: 'er',
- },
- {
- captures: [
- {
- end: 6,
- name: '1',
- start: 5,
- value: 'y',
- },
- {
- end: 7,
- name: '2',
- start: 6,
- value: 'r',
- },
- ],
- groups: [
- {
- end: 7,
- name: 'g',
- start: 6,
- value: 'r',
- },
- ],
- index: 5,
- value: 'yr',
- },
- ],
- },
-];
-
-describe('regex-tester', () => {
- for (const reg of regexesData) {
- const { regex, text, flags, result: expected_result } = reg;
- it(`Should matchRegex("${regex}","${text}","${flags}") return correct result`, async () => {
- const result = matchRegex(regex, text, `${flags}d`);
-
- expect(result).to.deep.equal(expected_result);
- });
- }
-});
diff --git a/src/tools/regex-tester/regex-tester.service.ts b/src/tools/regex-tester/regex-tester.service.ts
deleted file mode 100644
index ec8682c5..00000000
--- a/src/tools/regex-tester/regex-tester.service.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-interface RegExpGroupIndices {
- [name: string]: [number, number]
-}
-interface RegExpIndices extends Array<[number, number]> {
- groups: RegExpGroupIndices
-}
-interface RegExpExecArrayWithIndices extends RegExpExecArray {
- indices: RegExpIndices
-}
-interface GroupCapture {
- name: string
- value: string
- start: number
- end: number
-};
-
-export function matchRegex(regex: string, text: string, flags: string) {
- // if (regex === '' || text === '') {
- // return [];
- // }
-
- let lastIndex = -1;
- const re = new RegExp(regex, flags);
- const results = [];
- let match = re.exec(text) as RegExpExecArrayWithIndices;
- while (match !== null) {
- if (re.lastIndex === lastIndex || match[0] === '') {
- break;
- }
- const indices = match.indices;
- const captures: Array = [];
- Object.entries(match).forEach(([captureName, captureValue]) => {
- if (captureName !== '0' && captureName.match(/\d+/)) {
- captures.push({
- name: captureName,
- value: captureValue,
- start: indices[Number(captureName)][0],
- end: indices[Number(captureName)][1],
- });
- }
- });
- const groups: Array = [];
- Object.entries(match.groups || {}).forEach(([groupName, groupValue]) => {
- groups.push({
- name: groupName,
- value: groupValue,
- start: indices.groups[groupName][0],
- end: indices.groups[groupName][1],
- });
- });
- results.push({
- index: match.index,
- value: match[0],
- captures,
- groups,
- });
- lastIndex = re.lastIndex;
- match = re.exec(text) as RegExpExecArrayWithIndices;
- }
- return results;
-}
diff --git a/src/tools/regex-tester/regex-tester.vue b/src/tools/regex-tester/regex-tester.vue
deleted file mode 100644
index a1fa7958..00000000
--- a/src/tools/regex-tester/regex-tester.vue
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
-
-
-
-
- See Regular Expression Cheatsheet
-
-
-
- Global search. (g )
-
-
- Case-insensitive search. (i )
-
-
- Multiline(m )
-
-
- Singleline(s )
-
-
- Unicode(u )
-
-
- Unicode Sets (v )
-
-
-
-
-
-
-
-
-
-
-
-
-
- Index in text
- |
-
- Value
- |
-
- Captures
- |
-
- Groups
- |
-
-
-
-
- {{ match.index }} |
- {{ match.value }} |
-
-
- -
- "{{ capture.name }}" = {{ capture.value }} [{{ capture.start }} - {{ capture.end }}]
-
-
- |
-
-
- -
- "{{ group.name }}" = {{ group.value }} [{{ group.start }} - {{ group.end }}]
-
-
- |
-
-
-
-
- No match
-
-
-
-
- {{ sample }}
-
-
-
-
-
-
-
-
-
diff --git a/src/tools/tools.store.ts b/src/tools/tools.store.ts
index fb12450d..d952b7cb 100644
--- a/src/tools/tools.store.ts
+++ b/src/tools/tools.store.ts
@@ -14,7 +14,6 @@ export const useToolStore = defineStore('tools', () => {
return ({
...tool,
- path: tool.path,
name: t(`tools.${toolI18nKey}.title`, tool.name),
description: t(`tools.${toolI18nKey}.description`, tool.description),
category: t(`tools.categories.${tool.category.toLowerCase()}`, tool.category),
@@ -24,9 +23,8 @@ export const useToolStore = defineStore('tools', () => {
const toolsByCategory = computed(() => {
return _.chain(tools.value)
.groupBy('category')
- .map((components, name, path) => ({
+ .map((components, name) => ({
name,
- path,
components,
}))
.value();
@@ -34,7 +32,7 @@ export const useToolStore = defineStore('tools', () => {
const favoriteTools = computed(() => {
return favoriteToolsName.value
- .map(favoriteName => tools.value.find(({ name, path }) => name === favoriteName || path === favoriteName))
+ .map(favoriteName => tools.value.find(({ name }) => name === favoriteName))
.filter(Boolean) as ToolWithCategory[]; // cast because .filter(Boolean) does not remove undefined from type
});
@@ -45,23 +43,15 @@ export const useToolStore = defineStore('tools', () => {
newTools: computed(() => tools.value.filter(({ isNew }) => isNew)),
addToolToFavorites({ tool }: { tool: MaybeRef }) {
- const toolPath = get(tool).path;
- if (toolPath) {
- favoriteToolsName.value.push(toolPath);
- }
+ favoriteToolsName.value.push(get(tool).name);
},
removeToolFromFavorites({ tool }: { tool: MaybeRef }) {
- favoriteToolsName.value = favoriteToolsName.value.filter(name => get(tool).name !== name && get(tool).path !== name);
+ favoriteToolsName.value = favoriteToolsName.value.filter(name => get(tool).name !== name);
},
isToolFavorite({ tool }: { tool: MaybeRef }) {
- return favoriteToolsName.value.includes(get(tool).name)
- || favoriteToolsName.value.includes(get(tool).path);
- },
-
- updateFavoriteTools(newOrder: ToolWithCategory[]) {
- favoriteToolsName.value = newOrder.map(tool => tool.path);
+ return favoriteToolsName.value.includes(get(tool).name);
},
};
});
diff --git a/src/tools/xml-to-json/index.ts b/src/tools/xml-to-json/index.ts
deleted file mode 100644
index 8d83f4fe..00000000
--- a/src/tools/xml-to-json/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Braces } from '@vicons/tabler';
-import { defineTool } from '../tool';
-
-export const tool = defineTool({
- name: 'XML to JSON',
- path: '/xml-to-json',
- description: 'Convert XML to JSON',
- keywords: ['xml', 'json'],
- component: () => import('./xml-to-json.vue'),
- icon: Braces,
- createdAt: new Date('2024-08-09'),
-});
diff --git a/src/tools/xml-to-json/xml-to-json.vue b/src/tools/xml-to-json/xml-to-json.vue
deleted file mode 100644
index e1e5a477..00000000
--- a/src/tools/xml-to-json/xml-to-json.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
diff --git a/src/tools/yaml-to-json-converter/yaml-to-json.e2e.spec.ts b/src/tools/yaml-to-json-converter/yaml-to-json.e2e.spec.ts
index d6ed84c3..7b2a2d18 100644
--- a/src/tools/yaml-to-json-converter/yaml-to-json.e2e.spec.ts
+++ b/src/tools/yaml-to-json-converter/yaml-to-json.e2e.spec.ts
@@ -28,53 +28,4 @@ test.describe('Tool - Yaml to json', () => {
`.trim(),
);
});
-
- test('Yaml is parsed with merge key and output correct json', async ({ page }) => {
- await page.getByTestId('input').fill(`
- default: &default
- name: ''
- age: 0
-
- person:
- *default
-
- persons:
- - <<: *default
- age: 1
- - <<: *default
- name: John
- - { age: 3, <<: *default }
-
- `);
-
- const generatedJson = await page.getByTestId('area-content').innerText();
-
- expect(generatedJson.trim()).toEqual(
- `
-{
- "default": {
- "name": "",
- "age": 0
- },
- "person": {
- "name": "",
- "age": 0
- },
- "persons": [
- {
- "name": "",
- "age": 1
- },
- {
- "name": "John",
- "age": 0
- },
- {
- "age": 3,
- "name": ""
- }
- ]
-}`.trim(),
- );
- });
});
diff --git a/src/tools/yaml-to-json-converter/yaml-to-json.vue b/src/tools/yaml-to-json-converter/yaml-to-json.vue
index 72608add..39c9297f 100644
--- a/src/tools/yaml-to-json-converter/yaml-to-json.vue
+++ b/src/tools/yaml-to-json-converter/yaml-to-json.vue
@@ -6,7 +6,7 @@ import { withDefaultOnError } from '@/utils/defaults';
function transformer(value: string) {
return withDefaultOnError(() => {
- const obj = parseYaml(value, { merge: true });
+ const obj = parseYaml(value);
return obj ? JSON.stringify(obj, null, 3) : '';
}, '');
}
diff --git a/src/utils/base64.test.ts b/src/utils/base64.test.ts
index 51d15239..994f1b1b 100644
--- a/src/utils/base64.test.ts
+++ b/src/utils/base64.test.ts
@@ -38,8 +38,7 @@ describe('base64 utils', () => {
it('should throw for incorrect base64 string', () => {
expect(() => base64ToText('a')).to.throw('Incorrect base64 string');
- // should not really be false because trimming of space is now implied
- // expect(() => base64ToText(' ')).to.throw('Incorrect base64 string');
+ expect(() => base64ToText(' ')).to.throw('Incorrect base64 string');
expect(() => base64ToText('é')).to.throw('Incorrect base64 string');
// missing final '='
expect(() => base64ToText('bG9yZW0gaXBzdW0')).to.throw('Incorrect base64 string');
@@ -57,17 +56,17 @@ describe('base64 utils', () => {
it('should return false for incorrect base64 string', () => {
expect(isValidBase64('a')).to.eql(false);
+ expect(isValidBase64(' ')).to.eql(false);
expect(isValidBase64('é')).to.eql(false);
expect(isValidBase64('data:text/plain;notbase64,YQ==')).to.eql(false);
// missing final '='
expect(isValidBase64('bG9yZW0gaXBzdW0')).to.eql(false);
});
- it('should return true for untrimmed correct base64 string', () => {
- expect(isValidBase64('bG9yZW0gaXBzdW0= ')).to.eql(true);
- expect(isValidBase64(' LTE=')).to.eql(true);
- expect(isValidBase64(' YQ== ')).to.eql(true);
- expect(isValidBase64(' ')).to.eql(true);
+ it('should return false for untrimmed correct base64 string', () => {
+ expect(isValidBase64('bG9yZW0gaXBzdW0= ')).to.eql(false);
+ expect(isValidBase64(' LTE=')).to.eql(false);
+ expect(isValidBase64(' YQ== ')).to.eql(false);
});
});
diff --git a/src/utils/base64.ts b/src/utils/base64.ts
index 44e59f41..16912ee3 100644
--- a/src/utils/base64.ts
+++ b/src/utils/base64.ts
@@ -1,9 +1,7 @@
-import { Base64 } from 'js-base64';
-
export { textToBase64, base64ToText, isValidBase64, removePotentialDataAndMimePrefix };
function textToBase64(str: string, { makeUrlSafe = false }: { makeUrlSafe?: boolean } = {}) {
- const encoded = Base64.encode(str);
+ const encoded = window.btoa(str);
return makeUrlSafe ? makeUriSafe(encoded) : encoded;
}
@@ -18,7 +16,7 @@ function base64ToText(str: string, { makeUrlSafe = false }: { makeUrlSafe?: bool
}
try {
- return Base64.decode(cleanStr);
+ return window.atob(cleanStr);
}
catch (_) {
throw new Error('Incorrect base64 string');
@@ -36,11 +34,10 @@ function isValidBase64(str: string, { makeUrlSafe = false }: { makeUrlSafe?: boo
}
try {
- const reEncodedBase64 = Base64.fromUint8Array(Base64.toUint8Array(cleanStr));
if (makeUrlSafe) {
- return removePotentialPadding(reEncodedBase64) === cleanStr;
+ return removePotentialPadding(window.btoa(window.atob(cleanStr))) === cleanStr;
}
- return reEncodedBase64 === cleanStr.replace(/\s/g, '');
+ return window.btoa(window.atob(cleanStr)) === cleanStr;
}
catch (err) {
return false;
diff --git a/unocss.config.ts b/unocss.config.ts
index 14ee6940..e115c092 100644
--- a/unocss.config.ts
+++ b/unocss.config.ts
@@ -10,7 +10,7 @@ import {
import { presetScrollbar } from 'unocss-preset-scrollbar';
export default defineConfig({
- presets: [presetUno(), presetAttributify({ ignoreAttributes: ['size'] }), presetTypography(), presetScrollbar()],
+ presets: [presetUno(), presetAttributify(), presetTypography(), presetScrollbar()],
transformers: [transformerDirectives(), transformerVariantGroup()],
theme: {
colors: {
|