We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f17ca7 commit 4b1e37aCopy full SHA for 4b1e37a
services/github.py
@@ -0,0 +1,17 @@
1
+## Shorty
2
+## Copyright 2012 Andrea Stagi
3
+## See LICENSE
4
+
5
+## @url git.io
6
+class Github(Service):
7
8
+ def shrink(self, bigurl):
9
+ gitio_pattern = 'http(s)?://((gist|raw|develop(er)?)\.)?github\.com'
10
+ gitio_re = re.compile(gitio_pattern)
11
+ if not gitio_re.search(bigurl):
12
+ raise ShortyError('URL must match %s' % gitio_pattern)
13
+ resp = request('http://git.io', post_data="url=%s" % bigurl)
14
+ for header in resp.info().headers:
15
+ if header.startswith("Location:"):
16
+ return header[10:].strip('\n\r')
17
+ raise ShortyError('Failed to shrink url')
0 commit comments