Skip to content

Commit 91a101b

Browse files
committed
Fix raw download for GHE
1 parent 51317e6 commit 91a101b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nbviewer/providers/github/handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,12 @@ class GitHubBlobHandler(GithubClientMixin, RenderingHandler):
262262
@cached
263263
@gen.coroutine
264264
def get(self, user, repo, ref, path):
265-
raw_url = u"https://raw.githubusercontent.com/{user}/{repo}/{ref}/{path}".format(
266-
user=user, repo=repo, ref=ref, path=quote(path)
265+
if os.environ.get('GITHUB_API_URL', '') == '':
266+
raw_pattern = u"https://raw.githubusercontent.com/{user}/{repo}/{ref}/{path}"
267+
else: #Github Enterprise has a different URL pattern for accessing raw files
268+
raw_pattern = u"{github_url}{user}/{repo}/raw/{ref}/{path}"
269+
raw_url = raw_pattern.format(
270+
user=user, repo=repo, ref=ref, path=quote(path), github_url=self.github_url
267271
)
268272
blob_url = u"{github_url}{user}/{repo}/blob/{ref}/{path}".format(
269273
user=user, repo=repo, ref=ref, path=quote(path), github_url=_github_url()

0 commit comments

Comments
 (0)