mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 09:35:38 -05:00
Fix for user using command palette (#18948)
* fix for user using command palette command * rework if a user uses the create azure function via the command * for now only show in vs code * move logic to azureFunctionService + address comments * fix command location * address comments * fix validateFunction
This commit is contained in:
@@ -10,6 +10,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'fast-glob';
|
||||
import * as cp from 'child_process';
|
||||
import * as constants from '../common/constants';
|
||||
|
||||
export interface ValidationResult {
|
||||
errorMessage: string;
|
||||
@@ -162,6 +163,30 @@ export function escapeClosingBrackets(str: string): string {
|
||||
return str.replace(']', ']]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all special characters from object name
|
||||
* @param objectName can include brackets/periods and user entered special characters
|
||||
* @returns the object name without any special characters
|
||||
*/
|
||||
export function santizeObjectName(objectName: string): string {
|
||||
return objectName.replace(/[^a-zA-Z0-9 ]/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the input from user entered is valid
|
||||
* @param input from user input
|
||||
* @returns returns error if the input is empty or has special characters, undefined if the input is valid
|
||||
*/
|
||||
export function validateFunctionName(input: string): string | undefined {
|
||||
const specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
|
||||
if (!input) {
|
||||
return constants.nameMustNotBeEmpty;
|
||||
} else if (specialChars.test(input)) {
|
||||
return constants.hasSpecialCharacters;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the package info for the extension based on where the extension is installed
|
||||
* @returns the package info object
|
||||
|
||||
Reference in New Issue
Block a user