Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
contentLength as string
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Nov 12, 2019
1 parent d17701f commit 3d9935b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/src/components/templates/Asset/AssetFile.test.tsx
Expand Up @@ -14,7 +14,7 @@ const file = {
index: 0,
url: 'https://hello.com',
contentType: 'application/x-zip',
contentLength: 100
contentLength: '100'
}

const ddo = ({
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/templates/Asset/AssetFile.tsx
Expand Up @@ -119,11 +119,9 @@ export default class AssetFile extends PureComponent<
<ul key={index} className={styles.file}>
{contentType || contentLength ? (
<>
<li>{cleanupContentType(contentType)}</li>
<li>
{contentType && cleanupContentType(contentType)}
</li>
<li>
{contentLength && contentLength > 0
{contentLength && contentLength !== '0'
? filesize(contentLength)
: ''}
</li>
Expand Down
4 changes: 2 additions & 2 deletions client/src/routes/Publish/Files/Item.test.tsx
Expand Up @@ -8,7 +8,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip',
found: true,
contentType: 'application/zip',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />
Expand All @@ -21,7 +21,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip',
found: false,
contentType: '',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Publish/Files/Item.tsx
Expand Up @@ -11,7 +11,7 @@ const Item = ({
url: string
found: boolean
contentType: string
contentLength: number
contentLength: string
}
removeFile(): void
}) => (
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Publish/Files/index.test.tsx
Expand Up @@ -14,7 +14,7 @@ const files = [
url: 'https://hello.com',
checksum: 'cccccc',
checksumType: 'MD5',
contentLength: 100,
contentLength: '100',
contentType: 'application/zip',
resourceId: 'xxx',
encoding: 'UTF-8',
Expand Down
6 changes: 2 additions & 4 deletions server/src/routes/UrlCheckRouter.ts
Expand Up @@ -42,9 +42,7 @@ export class UrlCheckRouter {
result.found = true

if (headers['content-length']) {
result.contentLength = parseInt(
headers['content-length']
) // convert to number
result.contentLength = headers['content-length']
}

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

if (headers['content-type']) {
Expand Down

0 comments on commit 3d9935b

Please sign in to comment.