Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed html extension when making new snippet #470

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading