Skip to content

Commit

Permalink
Merge pull request #470 from bobrov-site/fixSnippetExtantion
Browse files Browse the repository at this point in the history
fixed html extension when making new snippet
  • Loading branch information
fey authored Apr 27, 2024
2 parents 3e2fd35 + 8a38779 commit 53d1680
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/Modals/NewSnippet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const icons = new Map()
const extensions = new Map()
.set('javascript', 'js')
.set('python', 'py')
.set('php', 'php');
.set('php', 'php')
.set('html', 'html');

const generateGuestUserData = () => {
const username = `guest_${faker.string.alphanumeric(5)}`;
Expand Down Expand Up @@ -107,7 +108,7 @@ function NewSnippet({ handleClose, isOpen }) {
// TODO: Тут не должно быть проверок, нужно создать абстракцию сервиса, который будет работать с любыми языками
if (supportedLanguages.includes(language)) {
try {
const snipName = `${values.name}.${extensions.get(language)}`;
const snipName = `${values.name}`;
const id = await snippetApi.saveSnippet(code, snipName, language);
const { slug } = await snippetApi.getSnippetData(id);
const url = new URL(
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/pages/profile/NewSnippetForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import SnippetCardWrapper from './SnippetCardWrapper';

import icons from '../../utils/icons';

const extensions = new Map()
.set('javascript', 'js')
.set('python', 'py')
.set('php', 'php')
.set('html', 'html');

function NewSnippetForm() {
const { t } = useTranslation();
const dispatch = useDispatch();
Expand All @@ -31,7 +25,7 @@ function NewSnippetForm() {
if (supportedLanguages.includes(language)) {
try {
const generatedName = await snippetApi.getDefaultSnippetName();
const snippetName = `${generatedName}.${extensions.get(language)}`;
const snippetName = `${generatedName}`;
const id = await snippetApi.saveSnippet(code, snippetName, language);
const { slug } = await snippetApi.getSnippetData(id);
const url = new URL(snippetApi.genViewSnippetLink(username, slug));
Expand Down

0 comments on commit 53d1680

Please sign in to comment.