Skip to content

Commit

Permalink
Merge pull request #66 from golnazads/master
Browse files Browse the repository at this point in the history
fixed validating url for python 3
  • Loading branch information
golnazads committed May 7, 2021
2 parents a1180d8 + 3aea343 commit 2b7f65f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion resolverway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from requests.exceptions import HTTPError, ConnectionError
import json
import urllib.request, urllib.parse, urllib.error
import re

from resolverway.log import log_request

Expand All @@ -24,6 +25,8 @@ class LinkRequest(object):
user_id = None
referrer = None

re_ads_link = re.compile(r"^(/abs/[12][09]\d\d[A-Za-z\.]{5}[A-Za-z0-9\.]{9}[A-Z]/abstract)$")

def __init__(self, bibcode, link_type, url=None, id=None):
self.bibcode = bibcode
self.link_type = link_type
Expand Down Expand Up @@ -176,8 +179,10 @@ def verify_url(self):
:return:
"""

url = urllib.parse.urlparse(self.url)
return all([url.scheme, url.netloc])
match = self.re_ads_link.match(self.url)
return all([url.scheme, url.netloc]) or match

def process_request(self):
"""
Expand Down

0 comments on commit 2b7f65f

Please sign in to comment.