Skip to content

Commit e69cdc9

Browse files
committed
Update live-view.js
1 parent 2c51157 commit e69cdc9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

live-view/live-view.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ async function handleLiveViewRequest(requestPath) {
10091009

10101010
// get public file from git as ReadableStream
10111011
respObj = await git.getPublicFileAsStream(liveFileDir, fileName);
1012+
10121013

10131014
// if couldn't fetch file
10141015
if (respObj.errorCode) {
@@ -1023,6 +1024,35 @@ async function handleLiveViewRequest(requestPath) {
10231024
};
10241025

10251026
}
1027+
1028+
1029+
// if the file's stored with Git LFS
1030+
// (see: https://github.com/git-lfs/git-lfs/blob/main/docs/spec.md)
1031+
1032+
const fileContentStr = new TextDecoder().decode(respObj);
1033+
1034+
const isLFS = fileContentStr.startsWith('version https://git-lfs.github.com/spec/');
1035+
1036+
if (isLFS) {
1037+
1038+
respObj = await git.getPublicLFSFileAsStream(liveFileDir, fileName);
1039+
1040+
1041+
// if couldn't fetch file
1042+
if (respObj.errorCode) {
1043+
1044+
// return an error
1045+
1046+
const respStatus = respObj.errorCode;
1047+
1048+
return {
1049+
fileContent: '',
1050+
respStatus: respStatus
1051+
};
1052+
1053+
}
1054+
1055+
}
10261056

10271057
} else {
10281058

0 commit comments

Comments
 (0)