Skip to content

Commit

Permalink
Adding HarPage.url attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Crown committed Jul 27, 2015
1 parent f0a1572 commit 93a974f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ file (see example above) with `har_data=har_data`::
### GET BASIC INFO
har_page.hostname
# 'humanssuck.net'
har_page.url
$ 'http://humanssuck.net/about/'

### WORK WITH LOAD TIMES (all load times are in ms) ###

Expand Down
7 changes: 7 additions & 0 deletions haralyzer/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ def hostname(self):
if header['name'] == 'Host':
return header['value']

@cached_property
def url(self):
"""
The absolute URL of the initial request.
"""
return self.entries[0]['request']['url']

@cached_property
def entries(self):
page_entries = []
Expand Down
9 changes: 9 additions & 0 deletions tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ def test_hostname(har_data):
assert page.hostname == 'humanssuck.net'


def test_url(har_data):
"""
Makes sure that the correct URL is returned.
"""
init_data = har_data('humanssuck.net.har')
page = HarPage(PAGE_ID, har_data=init_data)
assert page.url == 'http://humanssuck.net/'


def _correct_file_type(entry, file_types):
for header in entry['response']['headers']:
if header['name'] == 'Content-Type':
Expand Down

0 comments on commit 93a974f

Please sign in to comment.