Skip to content

Commit fffd462

Browse files
authored
Merge pull request #868 from ivan-gomes/ghe-raw-patch
Fix raw download for GHE
2 parents e2f7ee9 + c81c1cb commit fffd462

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

nbviewer/providers/github/handlers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
base64_decode,
3030
quote,
3131
response_text,
32+
url_path_join,
3233
)
3334

3435
from .client import AsyncGitHubClient
@@ -290,9 +291,14 @@ class GitHubBlobHandler(GithubClientMixin, RenderingHandler):
290291
"""
291292
@gen.coroutine
292293
def get_notebook_data(self, user, repo, ref, path):
293-
raw_url = u"https://raw.githubusercontent.com/{user}/{repo}/{ref}/{path}".format(
294-
user=user, repo=repo, ref=ref, path=quote(path)
295-
)
294+
if os.environ.get('GITHUB_API_URL', '') == '':
295+
raw_url = u"https://raw.githubusercontent.com/{user}/{repo}/{ref}/{path}".format(
296+
user=user, repo=repo, ref=ref, path=quote(path)
297+
)
298+
else: #Github Enterprise has a different URL pattern for accessing raw files
299+
raw_url = url_path_join(
300+
self.github_url, user, repo, 'raw', ref, quote(path)
301+
)
296302
blob_url = u"{github_url}{user}/{repo}/blob/{ref}/{path}".format(
297303
user=user, repo=repo, ref=ref, path=quote(path), github_url=self.github_url
298304
)

0 commit comments

Comments
 (0)