Skip to content

Commit

Permalink
Merge pull request #204 from harvard-lil/target-url-resolved
Browse files Browse the repository at this point in the history
Add `Scoop.targetUrlResolved`
  • Loading branch information
matteocargnelutti authored Sep 26, 2023
2 parents d46c298 + bbea1f6 commit a5d6370
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Scoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export class Scoop {
*/
url = ''

/**
* URL to capture, resolved to account for redirects.
* Populated during non-web content detection step.
* @type {string}
*/
targetUrlResolved = ''

/**
* Is the target url a web page?
* Assumed `true` until detected otherwise.
Expand Down Expand Up @@ -186,6 +193,7 @@ export class Scoop {
this.options = filterOptions(options)
this.blocklist = this.options.blocklist.map(castBlocklistMatcher)
this.url = this.filterUrl(url)
this.targetUrlResolved = this.url

// Logging setup (level, output formatting)
logPrefix.reg(this.log)
Expand Down Expand Up @@ -675,6 +683,7 @@ export class Scoop {

headRequestTimeMs = after - before

this.targetUrlResolved = headRequest.url
contentType = headRequest.headers.get('Content-Type')
contentLength = headRequest.headers.get('Content-Length')
} catch (err) {
Expand Down Expand Up @@ -1413,6 +1422,7 @@ export class Scoop {
state: this.state,
states: Object.keys(Scoop.states), // So summary.states[summary.state] = 'NAME-OF-STATE'
targetUrl: this.url,
targetUrlResolved: this.targetUrlResolved,
targetUrlIsWebPage: this.targetUrlIsWebPage,
targetUrlContentType: this.targetUrlContentType,
startedAt: this.startedAt,
Expand Down
1 change: 1 addition & 0 deletions Scoop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ await test('Scoop - capture of a web page.', async (t) => {
const summary = await capture.summary()
assert(summary)
assert.equal(summary.targetUrl, capture.url)
assert.equal(summary.targetUrlResolved, capture.targetUrlResolved)
assert.equal(summary.targetUrlContentType, 'text/html; charset=UTF-8')
assert.equal(summary.state, Scoop.states.COMPLETE)
assert.equal(summary.exchangeUrls.length, capture.exchanges.length)
Expand Down

0 comments on commit a5d6370

Please sign in to comment.