Skip to content

Commit 7987686

Browse files
authored
Merge pull request actions#17 from akamai/DEVPOPS-569_name_bug
fix bug where name wasn't being validated properly
2 parents 2f9de1e + a67dedd commit 7987686

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akamai-sandbox-cli",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "A tool to help manage Akamai Sandboxes. Uses the sandbox {OPEN} API.",
55
"repository": "https://github.com/akamai/cli-sandbox",
66
"scripts": {

src/cli-main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ program
413413
if (options.clonable) {
414414
sandbox.isClonable = clonable;
415415
}
416-
if (options.name) {
416+
if (isNonEmptyString(options.name)) {
417417
sandbox.name = options.name;
418418
}
419419

@@ -453,7 +453,7 @@ program
453453
.action(async function (arg, options) {
454454
try {
455455
const sandboxId = getSandboxIdFromIdentifier(arg);
456-
if (!options.name) {
456+
if (!isNonEmptyString(options.name)) {
457457
logAndExit('parameter --name is required');
458458
}
459459
const name = options.name;
@@ -725,6 +725,13 @@ function oneOf(...args: any[]) {
725725
return r;
726726
}
727727

728+
function isNonEmptyString(obj) {
729+
return obj !== null
730+
&& obj !== undefined
731+
&& (typeof obj === 'string')
732+
&& obj.trim().length > 0;
733+
}
734+
728735
program
729736
.command('create')
730737
.description('create a new sandbox')
@@ -753,7 +760,7 @@ program
753760
const hostnameSpecifier = options.hostname;
754761

755762
//validation
756-
if (!name) {
763+
if (!isNonEmptyString(name)) {
757764
logAndExit(`You must provide a name for your sandbox`);
758765
}
759766
if (!oneOf(propertySpecifier, papiFilePath, hostnameSpecifier)) {

0 commit comments

Comments
 (0)