| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | const { | |
| 25 | 25 | Boolean, | |
| 26 | 26 | Int8Array, | |
| 27 | + ObjectAssign, | ||
| 27 | 28 | ObjectKeys, | |
| 28 | 29 | StringPrototypeCharCodeAt, | |
| 29 | 30 | decodeURIComponent, | |
@@ -735,11 +736,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { | |||
| 735 | 736 | } | |
| 736 | 737 | ||
| 737 | 738 | const result = new Url(); | |
| 738 | - const tkeys = ObjectKeys(this); | ||
| 739 | - for (let tk = 0; tk < tkeys.length; tk++) { | ||
| 740 | - const tkey = tkeys[tk]; | ||
| 741 | - result[tkey] = this[tkey]; | ||
| 742 | - } | ||
| 739 | + ObjectAssign(result, this); | ||
| 743 | 740 | ||
| 744 | 741 | // Hash is always overridden, no matter what. | |
| 745 | 742 | // even href="" will remove it. | |
@@ -754,12 +751,13 @@ Url.prototype.resolveObject = function resolveObject(relative) { | |||
| 754 | 751 | // Hrefs like //foo/bar always cut to the protocol. | |
| 755 | 752 | if (relative.slashes && !relative.protocol) { | |
| 756 | 753 | // Take everything except the protocol from relative | |
| 757 | - const rkeys = ObjectKeys(relative); | ||
| 758 | - for (let rk = 0; rk < rkeys.length; rk++) { | ||
| 759 | - const rkey = rkeys[rk]; | ||
| 760 | - if (rkey !== 'protocol') | ||
| 761 | - result[rkey] = relative[rkey]; | ||
| 762 | - } | ||
| 754 | + const relativeWithoutProtocol = ObjectKeys(relative).reduce((acc, key) => { | ||
| 755 | + if (key !== 'protocol') { | ||
| 756 | + acc[key] = relative[key]; | ||
| 757 | + } | ||
| 758 | + return acc; | ||
| 759 | + }, {}); | ||
| 760 | + ObjectAssign(result, relativeWithoutProtocol); | ||
| 763 | 761 | ||
| 764 | 762 | // urlParse appends trailing / to urls like http://www.example.com | |
| 765 | 763 | if (slashedProtocol.has(result.protocol) && | |
@@ -781,11 +779,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { | |||
| 781 | 779 | // because that's known to be hostless. | |
| 782 | 780 | // anything else is assumed to be absolute. | |
| 783 | 781 | if (!slashedProtocol.has(relative.protocol)) { | |
| 784 | - const keys = ObjectKeys(relative); | ||
| 785 | - for (let v = 0; v < keys.length; v++) { | ||
| 786 | - const k = keys[v]; | ||
| 787 | - result[k] = relative[k]; | ||
| 788 | - } | ||
| 782 | + ObjectAssign(result, relative); | ||
| 789 | 783 | result.href = result.format(); | |
| 790 | 784 | return result; | |
| 791 | 785 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments