Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit761149c

Browse files
committed
Enable to pass an object to createBlob
createBlob automatically encodes string parameterby Utf8 library. In some cases the string valuecan be already encoded in Utf8 so the encodingshould be skipped.This commit enables to pass object containingthe content and encoding items. This object isdirectly sent to Github. Users have better controlabout what is actually sending.closes#463
1 parent22b889c commit761149c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎lib/Repository.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Repository extends Requestable {
245245
/**
246246
* Create a blob
247247
*@see https://developer.github.com/v3/git/blobs/#create-a-blob
248-
*@param {(string|Buffer|Blob)} content - the content to add to the repository
248+
*@param {(string|Buffer|Blob|Object)} content - the content to add to the repository
249249
*@param {Requestable.callback} cb - will receive the details of the created blob
250250
*@return {Promise} - the promise for the http request
251251
*/
@@ -258,7 +258,7 @@ class Repository extends Requestable {
258258

259259
/**
260260
* Get the object that represents the provided content
261-
*@param {string|Buffer|Blob} content - the content to send to the server
261+
*@param {string|Buffer|Blob|Object} content - the content to send to the server
262262
*@return {Object} the representation of `content` for the GitHub API
263263
*/
264264
_getContentObject(content){
@@ -283,9 +283,18 @@ class Repository extends Requestable {
283283
encoding:'base64',
284284
};
285285

286+
}elseif(typeofcontent==='object'){
287+
log('content is an object');
288+
289+
if(typeofcontent.content!=='string'){
290+
thrownewError('The object must contain content item of type string.');
291+
}
292+
293+
returncontent;
294+
286295
}else{// eslint-disable-line
287296
log(`Not sure what this content is:${typeofcontent},${JSON.stringify(content)}`);
288-
thrownewError('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
297+
thrownewError('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web) or Object');
289298
}
290299
}
291300

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp