Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parser function and replaced rsplit with url_parser #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tiyingxu
Copy link
Contributor

I created a url splitting function in utils.py and replaced all instances of rsplit in models.py with the new function url_parser().

@tiyingxu tiyingxu self-assigned this Nov 21, 2018
@tiyingxu tiyingxu requested a review from hongee November 21, 2018 03:34
Copy link
Contributor

@hongee hongee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made a few comments!

@@ -30,6 +30,13 @@ def replace_url(fn):
text = IMAGE_REGEX.sub(replace_url,package.cached_article_preview)
return text

def url_parser(url_string):
domain = url_string.split("?")
separate = domain[0].split('/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a couple of potential issues with this approach - the "/" can show up in multiple places, and I can't recall if urls can only contain one ?. Have you tried looking at https://docs.python.org/3/library/urllib.parse.html?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants