Skip to content

Commit 752b947

Browse files
kaushlakersLee Adams
authored andcommitted
[JS] - When defaulting do not merge objects (#276)
1 parent b3f0ae5 commit 752b947

File tree

9 files changed

+2962
-147
lines changed

9 files changed

+2962
-147
lines changed

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "twitter-text",
33
"description": "official twitter text linkification",
4-
"version": "3.0.0",
4+
"version": "3.0.1",
55
"main": "dist/index.js",
66
"files": [
77
"dist"

js/pkg/twitter-text-3.0.1.js

Lines changed: 2956 additions & 0 deletions
Large diffs are not rendered by default.

js/pkg/twitter-text-3.0.1.min.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/configs/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

js/src/parseTweet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import urlHasHttps from './regexp/urlHasHttps';
2828
* displayRangeEnd {int} end index of display text (inclusive) in utf16
2929
*/
3030
const parseTweet = function(text = '', options = configs.defaults) {
31-
const mergedOptions = { ...configs.defaults, ...options };
31+
const mergedOptions = Object.keys(options).length ? options : configs.defaults;
3232
const { defaultWeight, emojiParsingEnabled, scale, maxWeightedTweetLength, transformedURLLength } = mergedOptions;
3333
const normalizedText = typeof String.prototype.normalize === 'function' ? text.normalize() : text;
3434

js/src/regexp/emoji.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

js/src/regexp/validSpecialShortDomain.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

js/test/conformance.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
};
150150
case "WeightedTweetsCounterTest":
151151
return function(test) {
152-
return twttr.txt.parseTweet(test.text);
152+
return twttr.txt.parseTweet(test.text, twttr.txt.configs.version2);
153153
}
154154
case "WeightedTweetsWithDiscountedEmojiCounterTest":
155155
return function(test) {

js/test/tests.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,6 @@ test("twttr.txt.extractUrls", function() {
313313
equal(twttr.txt.extractUrls(message_with_www_hyphenated_url)[0], "www.123-hyphenated-url.com", "Should extract full url with hyphen.");
314314
});
315315

316-
test("twttr.txt.getTweetLength", function() {
317-
var config = twttr.txt.configs.version2;
318-
equal(twttr.txt.getTweetLength(""), 0, "empty should be zero length.");
319-
equal(twttr.txt.getTweetLength("sample tweet"), 12, "small tweet should be counted correctly.");
320-
equal(twttr.txt.getTweetLength("sample tweet with short url http://t.co/1"), 51, "Should count short URLs as 23");
321-
equal(twttr.txt.getTweetLength("sample tweet with short url http://t.co/this_is_really_really_really_really_really_long"), 94, "Should count long URLs as 23");
322-
323-
// With override configs
324-
equal(twttr.txt.getTweetLength("sample tweet", config), 12, "small tweet should be counted correctly with config");
325-
equal(twttr.txt.getTweetLength("sample tweet with short url http://t.co/this_is_really_really_really_really_really_long", config), 94, "Should count long URLs as 23 with config");
326-
});
327-
328316
test("twttr.txt.parseTweet", function() {
329317
var configVersion1 = twttr.txt.configs.version1;
330318
var configVersion2 = twttr.txt.configs.version2;

0 commit comments

Comments
 (0)