-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[BUGFIX release] Remove ember-fetch dependency. #6082
Merged
runspired
merged 2 commits into
emberjs:release
from
rwjblue:backport-release-fetch-changes
May 2, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Function that always attempts to parse the response as json, and if an error is thrown, | ||
* returns `undefined` if the response is successful and has a status code of 204 (No Content), | ||
* or 205 (Reset Content) or if the request method was 'HEAD', and the plain payload otherwise. | ||
*/ | ||
export function determineBodyPromise( | ||
response: Response, | ||
requestData: JQueryAjaxSettings | ||
): Promise<object | string | undefined> { | ||
return response.text().then(function(payload) { | ||
let ret: string | object | undefined = payload; | ||
try { | ||
ret = JSON.parse(payload); | ||
} catch (error) { | ||
if (!(error instanceof SyntaxError)) { | ||
throw error; | ||
} | ||
const status = response.status; | ||
if ( | ||
response.ok && | ||
(status === 204 || status === 205 || requestData.method === 'HEAD') | ||
) { | ||
ret = undefined; | ||
} else { | ||
console.warn('This response was unable to be parsed as json.', payload); | ||
} | ||
} | ||
return ret; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import require, { has } from 'require'; | ||
|
||
type MaybeFetch = { | ||
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>; | ||
} | null; | ||
|
||
let _fetch: MaybeFetch = null; | ||
|
||
if (has('fetch')) { | ||
// use `fetch` module by default, this is commonly provided by ember-fetch | ||
_fetch = require('fetch').default; | ||
} else if (typeof fetch === 'function') { | ||
// fallback to using global fetch | ||
_fetch = fetch; | ||
} | ||
|
||
export default _fetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const RBRACKET = /\[\]$/; | ||
|
||
function isPlainObject(obj: any): boolean { | ||
return Object.prototype.toString.call(obj) === '[object Object]'; | ||
} | ||
|
||
/** | ||
* Helper function that turns the data/body of a request into a query param string. | ||
* This is directly copied from jQuery.param. | ||
*/ | ||
export function serializeQueryParams( | ||
queryParamsObject: object | string | ||
): string { | ||
var s: any[] = []; | ||
|
||
function buildParams(prefix: string, obj: any) { | ||
var i, len, key; | ||
|
||
if (prefix) { | ||
if (Array.isArray(obj)) { | ||
for (i = 0, len = obj.length; i < len; i++) { | ||
if (RBRACKET.test(prefix)) { | ||
add(s, prefix, obj[i]); | ||
} else { | ||
buildParams( | ||
prefix + '[' + (typeof obj[i] === 'object' ? i : '') + ']', | ||
obj[i] | ||
); | ||
} | ||
} | ||
} else if (isPlainObject(obj)) { | ||
for (key in obj) { | ||
buildParams(prefix + '[' + key + ']', obj[key]); | ||
} | ||
} else { | ||
add(s, prefix, obj); | ||
} | ||
} else if (Array.isArray(obj)) { | ||
for (i = 0, len = obj.length; i < len; i++) { | ||
add(s, obj[i].name, obj[i].value); | ||
} | ||
} else { | ||
for (key in obj) { | ||
buildParams(key, obj[key]); | ||
} | ||
} | ||
return s; | ||
} | ||
|
||
return buildParams('', queryParamsObject) | ||
.join('&') | ||
.replace(/%20/g, '+'); | ||
} | ||
|
||
/** | ||
* Part of the `serializeQueryParams` helper function. | ||
*/ | ||
function add(s: Array<any>, k: string, v?: string | (() => string)) { | ||
// Strip out keys with undefined value and replace null values with | ||
// empty strings (mimics jQuery.ajax) | ||
if (v === undefined) { | ||
return; | ||
} else if (v === null) { | ||
v = ''; | ||
} | ||
|
||
v = typeof v === 'function' ? v() : v; | ||
s[s.length] = `${encodeURIComponent(k)}=${encodeURIComponent(v)}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1083,7 +1083,7 @@ abbrev@1: | |
resolved "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" | ||
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== | ||
|
||
abortcontroller-polyfill@^1.1.9, abortcontroller-polyfill@^1.2.5: | ||
abortcontroller-polyfill@^1.1.9: | ||
version "1.2.9" | ||
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.2.9.tgz#402311d2aac7e8e093ecb045726b45fdafd834fe" | ||
integrity sha512-0goWhDrwoWtK6XCdFdzPtvHBmmQU91j3tULNL85MAnDuM7bNlzUDfmL5AZGL819L7pn9kra35HJGWG25UgRCBw== | ||
|
@@ -2234,7 +2234,7 @@ broccoli-clean-css@^1.1.0: | |
inline-source-map-comment "^1.0.5" | ||
json-stable-stringify "^1.0.0" | ||
|
||
broccoli-concat@^3.2.2, broccoli-concat@^3.7.3: | ||
broccoli-concat@^3.7.3: | ||
version "3.7.3" | ||
resolved "https://registry.npmjs.org/broccoli-concat/-/broccoli-concat-3.7.3.tgz#0dca01311567ffb13180e6b4eb111824628e4885" | ||
integrity sha512-2Ma9h81EJ0PRb9n4sW0i8KZlcnpTQfKxcj87zvi5DFe1fd8CTDEdseHDotK2beuA2l+LbgVPfd8EHaBJKm/Y8g== | ||
|
@@ -2560,17 +2560,6 @@ broccoli-string-replace@^0.1.2: | |
broccoli-persistent-filter "^1.1.5" | ||
minimatch "^3.0.3" | ||
|
||
broccoli-templater@^2.0.1: | ||
version "2.0.2" | ||
resolved "https://registry.npmjs.org/broccoli-templater/-/broccoli-templater-2.0.2.tgz#285a892071c0b3ad5ebc275d9e8b3465e2d120d6" | ||
integrity sha512-71KpNkc7WmbEokTQpGcbGzZjUIY1NSVa3GB++KFKAfx5SZPUozCOsBlSTwxcv8TLoCAqbBnsX5AQPgg6vJ2l9g== | ||
dependencies: | ||
broccoli-plugin "^1.3.1" | ||
fs-tree-diff "^0.5.9" | ||
lodash.template "^4.4.0" | ||
rimraf "^2.6.2" | ||
walk-sync "^0.3.3" | ||
|
||
broccoli-test-helper@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.npmjs.org/broccoli-test-helper/-/broccoli-test-helper-2.0.0.tgz#1cfbb76f7e856ad8df96d55ee2f5e0dddddf5d4f" | ||
|
@@ -2655,7 +2644,7 @@ browserslist@^3.2.6: | |
caniuse-lite "^1.0.30000844" | ||
electron-to-chromium "^1.3.47" | ||
|
||
browserslist@^4.0.0, browserslist@^4.3.4: | ||
browserslist@^4.3.4: | ||
version "4.4.2" | ||
resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.4.2.tgz#6ea8a74d6464bb0bd549105f659b41197d8f0ba2" | ||
integrity sha512-ISS/AIAiHERJ3d45Fz0AVYKkgcy+F/eJHzKEvv1j0wwKGKD9T3BrwKr/5g45L+Y4XIK5PlTqefHciRFcfE1Jxg== | ||
|
@@ -2766,17 +2755,7 @@ can-symlink@^1.0.0: | |
dependencies: | ||
tmp "0.0.28" | ||
|
||
caniuse-api@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" | ||
integrity sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw== | ||
dependencies: | ||
browserslist "^4.0.0" | ||
caniuse-lite "^1.0.0" | ||
lodash.memoize "^4.1.2" | ||
lodash.uniq "^4.5.0" | ||
|
||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000939: | ||
caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000939: | ||
version "1.0.30000942" | ||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000942.tgz#454139b28274bce70bfe1d50c30970df7430c6e4" | ||
integrity sha512-wLf+IhZUy2rfz48tc40OH7jHjXjnvDFEYqBHluINs/6MgzoNLPf25zhE4NOVzqxLKndf+hau81sAW0RcGHIaBQ== | ||
|
@@ -3466,7 +3445,7 @@ ember-cli-babel-plugin-helpers@^1.0.0, ember-cli-babel-plugin-helpers@^1.1.0: | |
resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.1.0.tgz#de3baedd093163b6c2461f95964888c1676325ac" | ||
integrity sha512-Zr4my8Xn+CzO0gIuFNXji0eTRml5AxZUTDQz/wsNJ5AJAtyFWCY4QtKdoELNNbiCVGt1lq5yLiwTm4scGKu6xA== | ||
|
||
ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2, ember-cli-babel@^6.9.0: | ||
ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.9.0: | ||
version "6.18.0" | ||
resolved "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz#3f6435fd275172edeff2b634ee7b29ce74318957" | ||
integrity sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA== | ||
|
@@ -3894,24 +3873,6 @@ ember-export-application-global@^2.0.0: | |
dependencies: | ||
ember-cli-babel "^6.0.0-beta.7" | ||
|
||
ember-fetch@^6.5.0: | ||
version "6.5.0" | ||
resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-6.5.0.tgz#efed80b3dd2259b52efce7498659e9125235bfb7" | ||
integrity sha512-B9KSeeO3xDNMQ22JqNwbmgnOprBzc8kNVfQMtzkAmugMb2aCmBZohAlQlwUUX5ODz8fHq2xfuZXDHD81Dzb0vg== | ||
dependencies: | ||
abortcontroller-polyfill "^1.2.5" | ||
broccoli-concat "^3.2.2" | ||
broccoli-debug "^0.6.5" | ||
broccoli-merge-trees "^3.0.0" | ||
broccoli-rollup "^2.1.1" | ||
broccoli-stew "^2.0.0" | ||
broccoli-templater "^2.0.1" | ||
calculate-cache-key-for-tree "^1.1.0" | ||
caniuse-api "^3.0.0" | ||
ember-cli-babel "^6.8.2" | ||
node-fetch "^2.3.0" | ||
whatwg-fetch "^3.0.0" | ||
|
||
ember-inflector@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.npmjs.org/ember-inflector/-/ember-inflector-3.0.0.tgz#7e1ee8aaa0fa773ba0905d8b7c0786354d890ee1" | ||
|
@@ -6256,11 +6217,6 @@ lodash.keys@~2.3.0: | |
lodash._shimkeys "~2.3.0" | ||
lodash.isobject "~2.3.0" | ||
|
||
lodash.memoize@^4.1.2: | ||
version "4.1.2" | ||
resolved "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" | ||
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= | ||
|
||
lodash.merge@^4.3.1, lodash.merge@^4.6.0: | ||
version "4.6.1" | ||
resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" | ||
|
@@ -6324,7 +6280,7 @@ lodash.templatesettings@~2.3.0: | |
lodash._reinterpolate "~2.3.0" | ||
lodash.escape "~2.3.0" | ||
|
||
lodash.uniq@^4.2.0, lodash.uniq@^4.5.0: | ||
lodash.uniq@^4.2.0: | ||
version "4.5.0" | ||
resolved "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" | ||
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= | ||
|
@@ -6750,11 +6706,6 @@ [email protected]: | |
dependencies: | ||
object.getownpropertydescriptors "^2.0.3" | ||
|
||
node-fetch@^2.3.0: | ||
version "2.3.0" | ||
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5" | ||
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA== | ||
|
||
node-int64@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️