Comparing version 0.9.11 to 0.9.12
@@ -7,2 +7,3 @@ 'use strict'; | ||
js2xmlparser = require("js2xmlparser"), | ||
utils = require('./../utils'), | ||
model = require('./../xml/BlobListXmlModel'); | ||
@@ -25,5 +26,11 @@ | ||
response.addHttpProperty(N.CONTENT_TYPE, 'application/xml'); | ||
const transformedModel = this._transformBlobList(response.payload, query); | ||
const blobPrefixes = []; | ||
const transformedModel = this._transformBlobList(response.payload, query, blobPrefixes); | ||
let xmlDoc = js2xmlparser.parse('EnumerationResults', transformedModel); | ||
xmlDoc = xmlDoc.replace(`<EnumerationResults>`, `<EnumerationResults ServiceEndpoint="http://localhost:10000/devstoreaccount1" ContainerName="${request.containerName}">`); | ||
if (blobPrefixes.length > 0) { | ||
xmlDoc = xmlDoc.replace(`<BlobPrefix></BlobPrefix>`, model.blobPrefixesToXml(blobPrefixes)); | ||
} else { | ||
xmlDoc = xmlDoc.replace(`<BlobPrefix></BlobPrefix>`, ''); | ||
} | ||
xmlDoc = xmlDoc.replace(/\>[\s]+\</g, '><'); | ||
@@ -35,3 +42,3 @@ res.set(response.httpProps); | ||
_transformBlobList(blobList, query) { | ||
_transformBlobList(blobList, query, blobPrefixes) { | ||
let xmlBlobListModel = new model.BlobList(); | ||
@@ -41,12 +48,20 @@ (query.prefix === undefined) ? delete xmlBlobListModel.Prefix : xmlBlobListModel.Prefix = query.prefix; | ||
(query.marker === undefined) ? delete xmlBlobListModel.Marker : xmlBlobListModel.Marker = query.marker; | ||
if (query.delimiter) { | ||
xmlBlobListModel.BlobPrefix.name = query.delimiter; | ||
} else { | ||
delete xmlBlobListModel.BlobPrefix; | ||
} | ||
(query.delimiter === undefined) ? delete xmlBlobListModel.Delimiter : xmlBlobListModel.Delimiter = query.delimiter; | ||
if (query.delimiter !== undefined) { | ||
blobList = blobList.filter((blob) => { | ||
const blobName = blob.original.name; | ||
const restOfName = blobName.substr(blobName.indexOf(query.delimiter) + 1, blobName.length); | ||
return restOfName.indexOf(query.delimiter) === -1; | ||
const restOfName = blobName.substr(query.prefix.length, blobName.length); | ||
const keep = restOfName.indexOf(query.delimiter) === -1; | ||
if (!keep) { | ||
if (restOfName.indexOf(query.delimiter) === -1) { | ||
// No add to BlobPrefix | ||
} else { | ||
const blobPrefix = `${query.prefix}${restOfName.split(query.delimiter)[0]}${query.delimiter}`; | ||
if (!blobPrefixes.includes(blobPrefix)) { | ||
blobPrefixes.push(blobPrefix); | ||
} | ||
} | ||
} | ||
return keep; | ||
}); | ||
@@ -53,0 +68,0 @@ } |
@@ -11,8 +11,7 @@ 'use strict'; | ||
this.MaxResults = ''; | ||
this.Delimiter = ''; | ||
this.Blobs = { | ||
Blob: [] | ||
Blob: [], | ||
BlobPrefix: '' | ||
}; | ||
this.BlobPrefix = { | ||
name: '' | ||
}; | ||
this.NextMarker; | ||
@@ -50,5 +49,14 @@ } | ||
function blobPrefixesToXml(blobPrefixes) { | ||
let xml = ''; | ||
for(const prefix of blobPrefixes) { | ||
xml += `<BlobPrefix><Name>${prefix}</Name></BlobPrefix>`; | ||
} | ||
return xml; | ||
} | ||
module.exports = { | ||
BlobList: BlobList, | ||
Blob: Blob | ||
Blob: Blob, | ||
blobPrefixesToXml: blobPrefixesToXml | ||
} |
{ | ||
"name": "azurite", | ||
"version": "0.9.11", | ||
"version": "0.9.12", | ||
"description": "A lightweight server clone of Azure Blob Storage that simulates most of the commands supported by it with minimal dependencies.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# 0.9 | ||
## 0.9.12 | ||
- fixes the fixes [#83](https://github.com/arafato/azurite/issues/83): ListBlobs delimiter is really working now | ||
## 0.9.11 | ||
- fixes [#83](https://github.com/arafato/azurite/issues/83): ListBlobs delimiter is working now | ||
## 0.9.10 | ||
- Azurite now uses a flat base64-encoded file hierarchy, see [https://github.com/arafato/azurite/issues/82](https://github.com/arafato/azurite/issues/82): | ||
- Azurite now uses a flat base64-encoded file hierarchy, see [#82](https://github.com/arafato/azurite/issues/82): |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241127
4339