1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

contentLength as string

This commit is contained in:
Matthias Kretschmann 2019-11-12 13:27:23 +01:00
parent ac5c66f0e9
commit 6282dbb5fc
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 9 additions and 13 deletions

View File

@ -14,7 +14,7 @@ const file = {
index: 0, index: 0,
url: 'https://hello.com', url: 'https://hello.com',
contentType: 'application/x-zip', contentType: 'application/x-zip',
contentLength: 100 contentLength: '100'
} }
const ddo = ({ const ddo = ({

View File

@ -119,11 +119,9 @@ export default class AssetFile extends PureComponent<
<ul key={index} className={styles.file}> <ul key={index} className={styles.file}>
{contentType || contentLength ? ( {contentType || contentLength ? (
<> <>
<li>{cleanupContentType(contentType)}</li>
<li> <li>
{contentType && cleanupContentType(contentType)} {contentLength && contentLength !== '0'
</li>
<li>
{contentLength && contentLength > 0
? filesize(contentLength) ? filesize(contentLength)
: ''} : ''}
</li> </li>

View File

@ -8,7 +8,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip', url: 'https://hello.com/hello.zip',
found: true, found: true,
contentType: 'application/zip', contentType: 'application/zip',
contentLength: 10 contentLength: '10'
} }
const { container } = render( const { container } = render(
<Item item={item} removeItem={() => null} /> <Item item={item} removeItem={() => null} />
@ -21,7 +21,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip', url: 'https://hello.com/hello.zip',
found: false, found: false,
contentType: '', contentType: '',
contentLength: 10 contentLength: '10'
} }
const { container } = render( const { container } = render(
<Item item={item} removeItem={() => null} /> <Item item={item} removeItem={() => null} />

View File

@ -11,7 +11,7 @@ const Item = ({
url: string url: string
found: boolean found: boolean
contentType: string contentType: string
contentLength: number contentLength: string
} }
removeFile(): void removeFile(): void
}) => ( }) => (

View File

@ -14,7 +14,7 @@ const files = [
url: 'https://hello.com', url: 'https://hello.com',
checksum: 'cccccc', checksum: 'cccccc',
checksumType: 'MD5', checksumType: 'MD5',
contentLength: 100, contentLength: '100',
contentType: 'application/zip', contentType: 'application/zip',
resourceId: 'xxx', resourceId: 'xxx',
encoding: 'UTF-8', encoding: 'UTF-8',

View File

@ -42,9 +42,7 @@ export class UrlCheckRouter {
result.found = true result.found = true
if (headers['content-length']) { if (headers['content-length']) {
result.contentLength = parseInt( result.contentLength = headers['content-length']
headers['content-length']
) // convert to number
} }
// sometimes servers send content-range header, // sometimes servers send content-range header,
@ -54,7 +52,7 @@ export class UrlCheckRouter {
!headers['content-length'] !headers['content-length']
) { ) {
const size = headers['content-range'].split('/')[1] const size = headers['content-range'].split('/')[1]
result.contentLength = parseInt(size) // convert to number result.contentLength = size
} }
if (headers['content-type']) { if (headers['content-type']) {