citp / news-disinformation-study

A research project on how web users consume, are exposed to, and share news online.
8 stars 2 forks source link

Implement library support for link shims and shorteners #19

Closed jonathanmayer closed 4 years ago

jonathanmayer commented 4 years ago

Probably the easiest way to do this is create a new module (e.g., WebScience.Utilities.LinkResolution) that can check whether a link needs resolution (i.e., matches a known shim or shortener) and can resolve a link (either by parsing URL parameters or making a request to the URL and checking the redirect.

Some additional thoughts:

PranayAnchuri commented 4 years ago

First version of short urls using fetch api : https://github.com/citp/web-science/commit/13bde320dae763b814dcad16e65ea7b7b1b8ea6c

raw url is sent from the corresponding content script via message passing

PS: Response headers are not set to get the "Location" of redirected url when using manual mode in fetch API.

https://fetch.spec.whatwg.org/#atomic-http-redirect-handling

jonathanmayer commented 4 years ago

First version of short urls using fetch api : 13bde32

Please implement this in a new utility module, because we'll want to use the functionality in other study modules (e.g., SocialMediaSharing).

PS: Response headers are not set to get the "Location" of redirected url when using manual mode in fetch API.

https://fetch.spec.whatwg.org/#atomic-http-redirect-handling

A possible workaround: use the Fetch API to fire off the initial request, then use the WebRequest API to read the Location header in the response.

jonathanmayer commented 4 years ago

One more thought on this: we should make sure to gracefully handle the situation where the resolution requires an HTTP(S) request, and that request doesn't get a response.

jonathanmayer commented 4 years ago

Mulled over a bit more how to accomplish link resolution with the limited WebExtension APIs. I think the way to go is something like…

See https://github.com/citp/web-science/issues/20#issuecomment-557696819 for thoughts on lists of URL shorteners/shims.

PranayAnchuri commented 4 years ago

Implemented a utility module 'LinkResolution' that resolves a url.