mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-15 20:01:28 +00:00
fix: improve URL validation in GenerateCodeItem (#5998)
* fix: improve URL validation in GenerateCodeItem Replaced direct URL validation with a new function to check for valid URLs and missing interpolations. * Update packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2deee11718
commit
17cc70f36e
@@ -14,6 +14,14 @@ import { useSelector } from 'react-redux';
|
||||
import { getAllVariables, getGlobalEnvironmentVariables } from 'utils/collections/index';
|
||||
import { resolveInheritedAuth } from './utils/auth-utils';
|
||||
|
||||
const TEMPLATE_VAR_PATTERN = /\{\{([^}]+)\}\}/g;
|
||||
|
||||
const validateURLWithVars = (url) => {
|
||||
const isValid = isValidUrl(url);
|
||||
const hasMissingInterpolations = TEMPLATE_VAR_PATTERN.test(url);
|
||||
return isValid && !hasMissingInterpolations;
|
||||
};
|
||||
|
||||
const GenerateCodeItem = ({ collectionUid, item, onClose, isExample = false, exampleUid = null }) => {
|
||||
const languages = getLanguages();
|
||||
const collection = useSelector(state => state.collections.collections?.find(c => c.uid === collectionUid));
|
||||
@@ -122,7 +130,7 @@ const GenerateCodeItem = ({ collectionUid, item, onClose, isExample = false, exa
|
||||
<CodeViewToolbar />
|
||||
|
||||
<div className="editor-container">
|
||||
{isValidUrl(finalUrl) ? (
|
||||
{validateURLWithVars(finalUrl) ? (
|
||||
<CodeView
|
||||
language={selectedLanguage}
|
||||
item={finalItem}
|
||||
|
||||
Reference in New Issue
Block a user