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

Throw error when SP URL is null. Closes #6012 #6044

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/m365/spo/commands/folder/folder-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe(commands.FOLDER_SET, () => {

it('fails validation if the webUrl option is not valid', async () => {
const actual = await command.validate({ options: { webUrl: 'abc', url: folderRelSiteUrl, name: newFolderName } }, commandInfo);
assert.strictEqual(actual, "abc is not a valid SharePoint Online site URL");
assert.strictEqual(actual, "'abc' is not a valid SharePoint Online site URL.");
});

it('passes validation when the url option specified', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe(commands.STORAGEENTITY_LIST, () => {
it('rejects invalid SharePoint Online URL', async () => {
const url = 'http://contoso';
const actual = await command.validate({ options: { appCatalogUrl: url } }, commandInfo);
assert.strictEqual(actual, `${url} is not a valid SharePoint Online site URL`);
assert.strictEqual(actual, `'${url}' is not a valid SharePoint Online site URL.`);
});

it('fails validation when no SharePoint Online app catalog URL specified', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe(commands.STORAGEENTITY_REMOVE, () => {
it('rejects invalid SharePoint Online URL', async () => {
const url = 'http://contoso';
const actual = await command.validate({ options: { appCatalogUrl: url, key: 'prop' } }, commandInfo);
assert.strictEqual(actual, `${url} is not a valid SharePoint Online site URL`);
assert.strictEqual(actual, `'${url}' is not a valid SharePoint Online site URL.`);
});

it('fails validation when no SharePoint Online app catalog URL specified', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe(commands.STORAGEENTITY_SET, () => {
it('rejects invalid SharePoint Online URL', async () => {
const url = 'http://contoso';
const actual = await command.validate({ options: { appCatalogUrl: url, key: 'prop', value: 'val' } }, commandInfo);
assert.strictEqual(actual, `${url} is not a valid SharePoint Online site URL`);
assert.strictEqual(actual, `'${url}' is not a valid SharePoint Online site URL.`);
});

it('handles promise rejection', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,12 @@ export const validation = {
},

isValidSharePointUrl(url: string): boolean | string {
if (!url) {
return false;
if (typeof url !== 'string') {
return 'SharePoint Online site URL must be a string.';
}

if (url.indexOf('https://') !== 0) {
return `${url} is not a valid SharePoint Online site URL`;
return `'${url}' is not a valid SharePoint Online site URL.`;
}
else {
return true;
Expand Down
Loading