Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed Mar 13, 2018
2 parents 471b2fc + 18826a0 commit a35e600
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ more details.
Changelog
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.1.1
------------------------------------------------------------------------------

- Update method for URLs with brackets.

1.1.0
------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion linkie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from .linkie import Linkie

__version__ = '1.1.0'
__version__ = '1.1.1'
10 changes: 7 additions & 3 deletions linkie/linkie.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import requests

# This isn't a perfect URL matcher, but should catch the large majority of URLs.
URL_REGEX = r'(?:https?|ftp)://[^\s/$.?#].[^\s`\'"\]>}]*'
URL_REGEX = r'(?:https?|ftp)://[^\s`\'"\]\)>}]+'


class Linkie:

Expand Down Expand Up @@ -112,8 +113,8 @@ def check_file(self, file_path):
# Remove extra trailing bracket if link containing brackets
# Within Markdown link syntax.
# [Wikipedia link](http://foo.com/blah_blah_(wikipedia))
if url.endswith(')') and url.count('(') < url.count(')'):
url = url[:-1]
if url.count('('):
url += url.count('(') * ')'
# Remove trailing characters
url = url.rstrip('!"#$%&\'*+,-./@:;=^_`|~')
print(' - Checking URL {} '.format(url), end='')
Expand Down Expand Up @@ -150,11 +151,14 @@ def save_url(self, url, status_code, broken):
}

def print_summary(self):
number_broken_links = self.count_broken_links()

print('\n=============================================')
print('SUMMARY')
print('=============================================')
print('{} file{} checked'.format(self.file_count, 's' if self.file_count != 1 else ''))
print('{} unique URL{} found'.format(len(self.urls), 's' if len(self.urls) != 1 else ''))
print('{} broken link{} found'.format(number_broken_links, 's' if number_broken_links != 1 else ''))

print('\nStatus code counts')
print('---------------------------------------------')
Expand Down

0 comments on commit a35e600

Please sign in to comment.