Skip to content

Commit

Permalink
🐛 : remove line feeds for large README.md files
Browse files Browse the repository at this point in the history
Github serves raw content in base 64 with line feeds for large files. We have to remove them before decoding the content.
  • Loading branch information
juwit committed Jan 9, 2020
1 parent f831373 commit 42d531c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class RegistryRawContent(private val registryType: RegistryType, privat
RegistryFile::class.java)

if(response.statusCode == HttpStatus.OK) {
return Optional.of(String(Base64.getDecoder().decode(response.body?.content)))
return Optional.of(String(Base64.getDecoder().decode(response.body?.content?.replace("\n",""))))
}
return Optional.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void getReadmeContent_shouldCallTheApi_andServeDecodedContent(){

var requestCaptor = ArgumentCaptor.forClass(HttpEntity.class);

var githubFile = new RegistryFile(Base64.encode("# Module Readme".getBytes()));
var githubFile = new RegistryFile(Base64.encode("# Module Readme".getBytes()) + "\n");
var response = new ResponseEntity<>(githubFile, HttpStatus.OK);

when(restTemplate.exchange(
Expand Down

0 comments on commit 42d531c

Please sign in to comment.