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

Surfaces redirects from URI-Ms. Closes #451 #452

Merged
merged 2 commits into from
Jul 27, 2018
Merged

Surfaces redirects from URI-Ms. Closes #451 #452

merged 2 commits into from
Jul 27, 2018

Conversation

machawk1
Copy link
Member

As documented, the regex to pull the part of the URI-M before the URI-R assumes a 14-digit string. This can be done more reliably but for now it fixes the issue of 3XXs not being replayed.

@machawk1 machawk1 requested a review from ibnesayeed July 27, 2018 22:30
@codecov
Copy link

codecov bot commented Jul 27, 2018

Codecov Report

Merging #452 into master will decrease coverage by 0.14%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #452      +/-   ##
=========================================
- Coverage   23.55%   23.4%   -0.15%     
=========================================
  Files           6       6              
  Lines        1125    1132       +7     
  Branches      169     171       +2     
=========================================
  Hits          265     265              
- Misses        843     850       +7     
  Partials       17      17
Impacted Files Coverage Δ
ipwb/replay.py 13.54% <0%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73a447d...7843bd0. Read the comment docs.

if status[0] == '3':
# Bad assumption that the URI-M will contain \d14 but works for now.
uriBeforeURIR = request.url[:re.search(r'/\d{14}/', request.url).end()]
newURIM = uriBeforeURIR + resp.headers['Location']
Copy link
Member

Choose a reason for hiding this comment

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

This will probably fail in many cases. I think the simplistic assumption made here is that extracted uriBeforeURIR is going to be a directory URI and stored Location header will be a relative path. Both of these are unrealistic assumptions. I think you can simply return the Location header without any modification and let the SW deal with it. I am not sure how will it behave in case of a full URIs (probably it will be caught by the SW too).

Copy link
Member Author

Choose a reason for hiding this comment

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

The location header prior to this is a URI-R. Without the prepending of the replay system, the redirect forwards the user to the live Web.

Copy link
Member Author

Choose a reason for hiding this comment

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

uriBeforeURIR ends up being http://localhost:5000/memento/12345678901234/.

Copy link
Member

Choose a reason for hiding this comment

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

I misunderstood the uriBeforeURIR earlier. However, Location header is not going to be a full URI all the time, it could very well be a relative or absolute path.

@machawk1 machawk1 merged commit a8bdf71 into master Jul 27, 2018
@machawk1 machawk1 deleted the issue-451 branch July 27, 2018 23:51
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