diff --git a/src/xml-parsers.js b/src/xml-parsers.js index d551a0d2..159ad562 100644 --- a/src/xml-parsers.js +++ b/src/xml-parsers.js @@ -222,7 +222,7 @@ const formatObjInfo = (content, opts = {}) => { lastModified, etag, size: Size, - versionId: VersionId, + versionId: String(VersionId), isLatest: IsLatest, isDeleteMarker: opts.IsDeleteMarker ? opts.IsDeleteMarker : false, } diff --git a/tests/unit/test.js b/tests/unit/test.js index 05e43ade..4fa256bb 100644 --- a/tests/unit/test.js +++ b/tests/unit/test.js @@ -29,6 +29,7 @@ import { partsRequired, } from '../../src/internal/helper.ts' import * as Minio from '../../src/minio.js' +import { parseListObjects } from '../../src/xml-parsers.ts' const Package = { version: 'development' } @@ -2078,3 +2079,43 @@ describe('IP Address Validations', () => { }) }) }) + +describe('xml-parser', function () { + describe('#listObjects()', function () { + it('should parse VersionId as string even if number is provided', function () { + const xml = ` + + + some-bucket + + / + 1000 + false + url + + + + true + 1234 + "767dedcb515a0e2d995ed95191b75484-29" + file.ext + 2023-07-12T14:41:46.000Z + 151306240 + + + false + file.ext + 2023-07-12T14:39:22.000Z + 5678 + + + ` + const { objects } = parseListObjects(xml) + + assert.equal(typeof objects[0].versionId, 'string') + assert.equal(objects[0].versionId, '1234') + assert.equal(typeof objects[1].versionId, 'string') + assert.equal(objects[1].versionId, '5678') + }) + }) +})