Skip to content

Commit

Permalink
parse the given URL correctly allowing https and port numbers (based …
Browse files Browse the repository at this point in the history
  • Loading branch information
brosner committed Oct 21, 2009
1 parent 6c2d027 commit 080e441
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions atomformat.py
Expand Up @@ -61,11 +61,16 @@ def rfc3339_date(date):
## based on django.utils.feedgenerator.get_tag_uri ## based on django.utils.feedgenerator.get_tag_uri
def get_tag_uri(url, date): def get_tag_uri(url, date):
"Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id" "Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id"
tag = re.sub('^http://', '', url) parts = urlparse.urlparse(url)
date_part = ""
if date is not None: if date is not None:
tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1) date_part = ",%s:" % date.strftime("%Y-%m-%d")
tag = re.sub('#', '/', tag) return "tag:%s%s%s/%s" % (
return 'tag:' + tag parts.hostname,
date_part,
parts.path,
parts.fragment,
)






Expand Down

0 comments on commit 080e441

Please sign in to comment.