Skip to content

Commit b37f5f7

Browse files
committed
feat(workflow): improve validation for Google Sheets ID input in edit component
1 parent 2cc5e70 commit b37f5f7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/newtab/workflow/edit/EditGoogleSheets.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,21 @@ const state = shallowReactive({
287287
288288
const checkPermission = debounce(async (value) => {
289289
try {
290+
if (!value.trim()) {
291+
toast.error('Spreadsheet id is empty');
292+
return;
293+
}
294+
295+
if (
296+
value.includes('://') ||
297+
value.startsWith('http') ||
298+
value.startsWith('www.') ||
299+
value.includes('docs.google.com')
300+
) {
301+
toast.error('Spreadsheet id is invalid');
302+
return;
303+
}
304+
290305
if (state.lastSheetId === value) return;
291306
292307
const response = await fetchApi(
@@ -313,7 +328,7 @@ async function previewData() {
313328
spreadsheetId: props.data.spreadsheetId,
314329
};
315330
316-
if (!props.data.spreadsheetId) {
331+
if (!props.data.spreadsheetId.trim()) {
317332
toast.error(
318333
props.googleDrive
319334
? 'No spreadsheet is selected'

0 commit comments

Comments
 (0)