Skip to content

Commit cb2f0da

Browse files
committed
Add missing uri_rewrites for GHE
Cases: * user/repo * user
1 parent 51317e6 commit cb2f0da

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

nbviewer/providers/github/handlers.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,27 @@ def uri_rewrites(rewrites=[]):
388388
]
389389
# github enterprise
390390
if os.environ.get('GITHUB_API_URL', '') != '':
391-
github_api_url = os.environ.get('GITHUB_API_URL')
391+
github_url = os.environ.get('GITHUB_API_URL').split('api/v3')[0]
392392

393393
github_rewrites.extend([
394394
# raw view
395-
(r'^' + github_api_url.split('/api/v3/')[0]
396-
+ '/([^\/]+)/([^\/]+)/raw/([^\/]+)/(.*)',
395+
(r'^' + github_url
396+
+ r'([^\/]+)/([^\/]+)/raw/([^\/]+)/(.*)',
397397
u'/github/{0}/{1}/blob/{2}/{3}'),
398398

399399
# trees & blobs
400-
(r'^' + github_api_url.split('/api/v3/')[0]
401-
+ '/([\w\-]+)/([^\/]+)/(blob|tree)/(.*)$',
400+
(r'^' + github_url
401+
+ r'([\w\-]+)/([^\/]+)/(blob|tree)/(.*)$',
402402
u'/github/{0}/{1}/{2}/{3}'),
403+
404+
# user/repo
405+
(r'^' + github_url
406+
+ r'([\w\-]+)/([^\/]+)/?$',
407+
u'/github/{0}/{1}/tree/master'),
408+
409+
# user
410+
(r'^' + github_url
411+
+ r'([\w\-]+)$',
412+
u'/github/{0}/'),
403413
])
404414
return rewrites + github_rewrites

0 commit comments

Comments
 (0)