mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
1 parent
4751417bf6
commit
2da9832fd9
2 files changed
+45
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import { Database } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'SQL Minifier',
|
||||
path: '/sql-minifier',
|
||||
description: 'Minify SQL queries',
|
||||
keywords: ['sql', 'query', 'minifier'],
|
||||
component: () => import('./sql-minifier.vue'),
|
||||
icon: Database,
|
||||
createdAt: new Date('2025-05-01'),
|
||||
category: 'Development',
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import _ from 'lodash';
|
||||
|
||||
const sqlQuery = ref(`select field1,field2,field3
|
||||
from my_table
|
||||
where my_condition = 'A Z E';`);
|
||||
const minifiedQuery = computed(() => {
|
||||
const quotedStrings: string[] = [];
|
||||
const queryWithoutQuotes = sqlQuery.value.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g, (match) => {
|
||||
quotedStrings.push(match);
|
||||
return `__QUOTE_PLACEHOLDER_${quotedStrings.length - 1}__`;
|
||||
});
|
||||
|
||||
let minified = _.trim(queryWithoutQuotes.replace(/\s+/g, ' '));
|
||||
|
||||
quotedStrings.forEach((quote, index) => {
|
||||
minified = minified.replace(`__QUOTE_PLACEHOLDER_${index}__`, quote);
|
||||
});
|
||||
|
||||
return minified;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card title="SQL Minifier">
|
||||
<c-input-text v-model:value="sqlQuery" label="SQL Query:" multiline mb-1 rows="10" placeholder="Enter SQL query..." />
|
||||
|
||||
<c-card title="Minified SQL Query">
|
||||
<textarea-copyable :value="minifiedQuery" language="sql" />
|
||||
</c-card>
|
||||
</c-card>
|
||||
</template>
|
||||
Reference in new issue
Block a user