Skip to content
Open
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
48 changes: 24 additions & 24 deletions e2e/filesystem-upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('FileSystemUpload end-to-end tests', function () {
await verifyExistsInAemAndHasEvents(uploadOptions, '/freeride-steep.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/ice-climbing.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, `/${ENCODED_ASSET1}`);
should(await doesAemPathExist(uploadOptions, '/dir-1')).not.be.ok();
should(await doesAemPathExist(uploadOptions, '/Dir 1')).not.be.ok();

return deleteAemPath(uploadOptions);
});
Expand Down Expand Up @@ -197,23 +197,23 @@ describe('FileSystemUpload end-to-end tests', function () {
retryErrors: [],
createdFolders: [
buildFolderResult(targetFolder, '/images', 'images', uploadResult.createdFolders[2].elapsedTime),
buildFolderResult(targetFolder, '/images/dir-1', 'Dir 1', uploadResult.createdFolders[3].elapsedTime),
buildFolderResult(targetFolder, '/images/dir-1/folder_♂♀°′″℃$£‰§№¢℡㈱', 'folder_♂♀°′″℃$£‰§№¢℡㈱', uploadResult.createdFolders[4].elapsedTime),
buildFolderResult(targetFolder, '/images/dir-1/subdir1', 'subdir1', uploadResult.createdFolders[5].elapsedTime),
buildFolderResult(targetFolder, '/images/dir-1/subdir2', 'subdir2', uploadResult.createdFolders[6].elapsedTime),
buildFolderResult(targetFolder, '/images/Dir 1', 'Dir 1', uploadResult.createdFolders[3].elapsedTime),
buildFolderResult(targetFolder, '/images/Dir 1/folder_♂♀°′″℃$£‰§№¢℡㈱', 'folder_♂♀°′″℃$£‰§№¢℡㈱', uploadResult.createdFolders[4].elapsedTime),
buildFolderResult(targetFolder, '/images/Dir 1/subdir1', 'subdir1', uploadResult.createdFolders[5].elapsedTime),
buildFolderResult(targetFolder, '/images/Dir 1/subdir2', 'subdir2', uploadResult.createdFolders[6].elapsedTime),
],
detailedResult: [
buildFileResult(targetFolder, '/images/Freeride-extreme.jpg', '/images/Freeride#extreme.jpg', 246578),
buildFileResult(targetFolder, '/images/climber-ferrata-la-torre-di-toblin.jpg', 'images/climber-ferrata-la-torre-di-toblin.jpg', 414164),
buildFileResult(targetFolder, '/images/freeride-siberia.jpg', 'images/freeride-siberia.jpg', 282584),
buildFileResult(targetFolder, '/images/dir-1/freeride-steep.jpg', '/images/Dir 1/freeride-steep.jpg', 320669),
buildFileResult(targetFolder, '/images/dir-1/freeride.jpg', '/images/Dir 1/freeride.jpg', 102189),
buildFileResult(targetFolder, '/images/dir-1/ice-climbing.jpg', '/images/Dir 1/ice-climbing.jpg', 166077),
buildFileResult(targetFolder, '/images/dir-1/이두吏讀.jpg', '/images/Dir 1/이두吏讀.jpg', 295623),
buildFileResult(targetFolder, '/images/dir-1/folder_♂♀°′″℃$£‰§№¢℡㈱/郎礼.jpg', '/images/Dir 1/folder_♂♀°′″℃$£‰§№¢℡㈱/郎礼.jpg', 161221),
buildFileResult(targetFolder, '/images/dir-1/subdir1/ski touring.jpg', '/images/Dir 1/subdir1/ski touring.jpg', 196310),
buildFileResult(targetFolder, '/images/dir-1/subdir1/skiing_2.jpg', '/images/Dir 1/subdir1/skiing_2.jpg', 245780),
buildFileResult(targetFolder, '/images/dir-1/subdir1/skiing_1.jpg', '/images/Dir 1/subdir1/skiing_1.jpg', 561767),
buildFileResult(targetFolder, '/images/Dir 1/freeride-steep.jpg', '/images/Dir 1/freeride-steep.jpg', 320669),
buildFileResult(targetFolder, '/images/Dir 1/freeride.jpg', '/images/Dir 1/freeride.jpg', 102189),
buildFileResult(targetFolder, '/images/Dir 1/ice-climbing.jpg', '/images/Dir 1/ice-climbing.jpg', 166077),
buildFileResult(targetFolder, '/images/Dir 1/이두吏讀.jpg', '/images/Dir 1/이두吏讀.jpg', 295623),
buildFileResult(targetFolder, '/images/Dir 1/folder_♂♀°′″℃$£‰§№¢℡㈱/郎礼.jpg', '/images/Dir 1/folder_♂♀°′″℃$£‰§№¢℡㈱/郎礼.jpg', 161221),
buildFileResult(targetFolder, '/images/Dir 1/subdir1/ski touring.jpg', '/images/Dir 1/subdir1/ski touring.jpg', 196310),
buildFileResult(targetFolder, '/images/Dir 1/subdir1/skiing_2.jpg', '/images/Dir 1/subdir1/skiing_2.jpg', 245780),
buildFileResult(targetFolder, '/images/Dir 1/subdir1/skiing_1.jpg', '/images/Dir 1/subdir1/skiing_1.jpg', 561767),
buildFileResult(targetFolder, '/climber-ferrata-la-torre-di-toblin.jpg', '/images/climber-ferrata-la-torre-di-toblin.jpg', 414164),
buildFileResult(targetFolder, '/skiing_1.jpg', 'images/Dir 1/subdir1/skiing_1.jpg', 561767),
],
Expand All @@ -229,22 +229,22 @@ describe('FileSystemUpload end-to-end tests', function () {
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/freeride-siberia.jpg');

// images/dir1
await verifyExistsInAemAndHasTitle(uploadOptions, '/images/dir-1', 'Dir 1');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/freeride.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/freeride-steep.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/ice-climbing.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, `/images/dir-1/${ENCODED_ASSET1}`);
await verifyExistsInAemAndHasTitle(uploadOptions, '/images/Dir 1', 'Dir 1');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/freeride.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/freeride-steep.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/ice-climbing.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, `/images/Dir 1/${ENCODED_ASSET1}`);

// images/dir1/subdir1
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/subdir1/ski touring.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/subdir1/skiing_1.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/dir-1/subdir1/skiing_2.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/subdir1/ski touring.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/subdir1/skiing_1.jpg');
await verifyExistsInAemAndHasEvents(uploadOptions, '/images/Dir 1/subdir1/skiing_2.jpg');

// images/dir1/folder_♂♀°′″℃$£‰§№¢℡㈱
await verifyExistsInAemAndHasEvents(uploadOptions, `/images/dir-1/${ENCODED_FOLDER}/${ENCODED_ASSET2}`);
await verifyExistsInAemAndHasEvents(uploadOptions, `/images/Dir 1/${ENCODED_FOLDER}/${ENCODED_ASSET2}`);

should(hasEventCheck('foldercreated', targetFolder, '/images/dir-1/subdir2', (data) => data.targetFolder)).be.ok();
should(await doesAemPathExist(uploadOptions, '/images/dir-1/subdir2')).be.ok();
should(hasEventCheck('foldercreated', targetFolder, '/images/Dir 1/subdir2', (data) => data.targetFolder)).be.ok();
should(await doesAemPathExist(uploadOptions, '/images/Dir 1/subdir2')).be.ok();

return deleteAemPath(uploadOptions);
});
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports.RegularExpressions = {
* Will match values that contain characters that are invalid in AEM folder node
* names.
*/
INVALID_FOLDER_CHARACTERS_REGEX: /[.%;#+?^{}\s"&]/g,
INVALID_FOLDER_CHARACTERS_REGEX: /[.%;#+?^{}"&]/g,

/**
* Will match values that contain characters that are invalid in AEM asset node
Expand Down
4 changes: 2 additions & 2 deletions test/filesystem-upload-item-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('FileSystemUploadItemManager Tests', () => {
const subChild = await manager.getDirectory('/fake/test/directory/Child Dir/Sub Child/');
should(subChild).be.ok();
should(subChild.getLocalPath()).be.exactly('/fake/test/directory/Child Dir/Sub Child');
should(subChild.getRemotePath()).be.exactly('/content/dam/target/directory/child-dir/sub-child');
should(subChild.getRemotePath()).be.exactly('/content/dam/target/directory/child dir/sub child');
should(subChild.getName()).be.exactly('Sub Child');
should(manager.hasDirectory('/fake/test/directory/')).be.ok();
should(manager.hasDirectory('/fake/test/directory/Child Dir')).be.ok();
Expand All @@ -44,7 +44,7 @@ describe('FileSystemUploadItemManager Tests', () => {
const child = await manager.getDirectory('/fake/test/directory/Child Dir');
should(child).be.ok();
should(child.getLocalPath()).be.exactly('/fake/test/directory/Child Dir');
should(child.getRemotePath()).be.exactly('/content/dam/target/directory/child-dir');
should(child.getRemotePath()).be.exactly('/content/dam/target/directory/child dir');
should(child.getName()).be.exactly('Child Dir');

should(manager.getDirectory('/fake/test')).be.rejected();
Expand Down
13 changes: 12 additions & 1 deletion test/filesystem-upload-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('FileSystemUploadOptions Tests', () => {
copiedOptions = FileSystemUploadOptions.fromOptions(fileOptions);
should(copiedOptions).be.ok();
should(copiedOptions.getInvalidCharacterReplaceValue()).be.exactly('-');
should(await copiedOptions.getFolderNodeNameProcessor()('folder name')).be.exactly('folder-name');
should(await copiedOptions.getFolderNodeNameProcessor()('folder name')).be.exactly('folder name');
should(await copiedOptions.getAssetNodeNameProcessor()('asset#name')).be.exactly('asset-name');
});

Expand Down Expand Up @@ -83,4 +83,15 @@ describe('FileSystemUploadOptions Tests', () => {
options.withInvalidCharacterReplaceValue(':');
});
});

it('test folder names with spaces', async () => {
// Test that spaces are preserved in folder names
should(await options.getFolderNodeNameProcessor()('My Folder')).be.exactly('my folder');
should(await options.getFolderNodeNameProcessor()('Folder With Spaces')).be.exactly('folder with spaces');
should(await options.getFolderNodeNameProcessor()('Folder-With-Hyphens')).be.exactly('folder-with-hyphens');

// Test that other invalid characters are still replaced
should(await options.getFolderNodeNameProcessor()('Folder#With#Hash')).be.exactly('folder-with-hash');
should(await options.getFolderNodeNameProcessor()('Folder%With%Percent')).be.exactly('folder-with-percent');
});
});
24 changes: 23 additions & 1 deletion test/filesystem-upload-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('FileSystemUploadUtils Tests', () => {
});

it('test clean folder name', async () => {
should(await cleanFolderName(options, 'A b:c.d')).be.exactly('a-b-c-d');
should(await cleanFolderName(options, 'A b:c.d')).be.exactly('a b-c-d');
options.withFolderNodeNameProcessor(async (folderName) => folderName)
.withInvalidCharacterReplaceValue('_');
should(await cleanFolderName(options, 'A b:c')).be.exactly('A b_c');
Expand All @@ -36,4 +36,26 @@ describe('FileSystemUploadUtils Tests', () => {
.withInvalidCharacterReplaceValue('_');
should(await cleanAssetName(options, 'A #b:c')).be.exactly('A #b_c');
});

it('test folder names with spaces', async () => {
// Test that spaces are preserved in folder names
should(await cleanFolderName(options, 'My Folder')).be.exactly('my folder');
should(await cleanFolderName(options, 'Folder With Spaces')).be.exactly('folder with spaces');
should(await cleanFolderName(options, 'Folder-With-Hyphens')).be.exactly('folder-with-hyphens');

// Test that other invalid characters are still replaced
should(await cleanFolderName(options, 'Folder#With#Hash')).be.exactly('folder-with-hash');
should(await cleanFolderName(options, 'Folder%With%Percent')).be.exactly('folder-with-percent');
});

it('test asset names with spaces', async () => {
// Test that spaces are preserved in asset names
should(await cleanAssetName(options, 'My File.jpg')).be.exactly('My File.jpg');
should(await cleanAssetName(options, 'File With Spaces.png')).be.exactly('File With Spaces.png');
should(await cleanAssetName(options, 'File-With-Hyphens.pdf')).be.exactly('File-With-Hyphens.pdf');

// Test that other invalid characters are still replaced
should(await cleanAssetName(options, 'File#With#Hash.jpg')).be.exactly('File-With-Hash.jpg');
should(await cleanAssetName(options, 'File%With%Percent.png')).be.exactly('File-With-Percent.png');
});
});