(err, _result)
| 753 | * @returns {void} |
| 754 | */ |
| 755 | const handleResult = (err, _result) => { |
| 756 | if (err) return callback(err); |
| 757 | |
| 758 | const result = /** @type {FetchResult} */ (_result); |
| 759 | |
| 760 | if ("location" in result) { |
| 761 | // Validate redirect target before following |
| 762 | /** @type {string} */ |
| 763 | let absolute; |
| 764 | try { |
| 765 | absolute = validateRedirectLocation(result.location, url); |
| 766 | } catch (err_) { |
| 767 | return callback(/** @type {Error} */ (err_)); |
| 768 | } |
| 769 | if (redirectCount >= MAX_REDIRECTS) { |
| 770 | return callback(new Error("Too many redirects")); |
| 771 | } |
| 772 | return resolveContent( |
| 773 | absolute, |
| 774 | integrity, |
| 775 | (err, innerResult) => { |
| 776 | if (err) return callback(err); |
| 777 | const { entry, content, storeLock } = |
| 778 | /** @type {ResolveContentResult} */ (innerResult); |
| 779 | callback(null, { |
| 780 | entry, |
| 781 | content, |
| 782 | storeLock: storeLock && result.storeLock |
| 783 | }); |
| 784 | }, |
| 785 | redirectCount + 1 |
| 786 | ); |
| 787 | } |
| 788 | |
| 789 | if ( |
| 790 | !result.fresh && |
| 791 | integrity && |
| 792 | result.entry.integrity !== integrity && |
| 793 | !verifyIntegrity(result.content, integrity) |
| 794 | ) { |
| 795 | return fetchContent.force(url, handleResult); |
| 796 | } |
| 797 | |
| 798 | return callback(null, { |
| 799 | entry: result.entry, |
| 800 | content: result.content, |
| 801 | storeLock: result.storeLock |
| 802 | }); |
| 803 | }; |
| 804 | |
| 805 | fetchContent(url, handleResult); |
| 806 | }; |
nothing calls this directly
no test coverage detected