Skip to content

Commit

Permalink
[JS] - When defaulting do not merge objects (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushlakers authored and Lee Adams committed Dec 18, 2018
1 parent b3f0ae5 commit 752b947
Show file tree
Hide file tree
Showing 9 changed files with 2,962 additions and 147 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "twitter-text",
"description": "official twitter text linkification",
"version": "3.0.0",
"version": "3.0.1",
"main": "dist/index.js",
"files": [
"dist"
Expand Down
2,956 changes: 2,956 additions & 0 deletions js/pkg/twitter-text-3.0.1.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions js/pkg/twitter-text-3.0.1.min.js

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions js/src/configs/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion js/src/parseTweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import urlHasHttps from './regexp/urlHasHttps';
* displayRangeEnd {int} end index of display text (inclusive) in utf16
*/
const parseTweet = function(text = '', options = configs.defaults) {
const mergedOptions = { ...configs.defaults, ...options };
const mergedOptions = Object.keys(options).length ? options : configs.defaults;
const { defaultWeight, emojiParsingEnabled, scale, maxWeightedTweetLength, transformedURLLength } = mergedOptions;
const normalizedText = typeof String.prototype.normalize === 'function' ? text.normalize() : text;

Expand Down
111 changes: 0 additions & 111 deletions js/src/regexp/emoji.js

This file was deleted.

10 changes: 0 additions & 10 deletions js/src/regexp/validSpecialShortDomain.js

This file was deleted.

2 changes: 1 addition & 1 deletion js/test/conformance.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
};
case "WeightedTweetsCounterTest":
return function(test) {
return twttr.txt.parseTweet(test.text);
return twttr.txt.parseTweet(test.text, twttr.txt.configs.version2);
}
case "WeightedTweetsWithDiscountedEmojiCounterTest":
return function(test) {
Expand Down
12 changes: 0 additions & 12 deletions js/test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,6 @@ test("twttr.txt.extractUrls", function() {
equal(twttr.txt.extractUrls(message_with_www_hyphenated_url)[0], "www.123-hyphenated-url.com", "Should extract full url with hyphen.");
});

test("twttr.txt.getTweetLength", function() {
var config = twttr.txt.configs.version2;
equal(twttr.txt.getTweetLength(""), 0, "empty should be zero length.");
equal(twttr.txt.getTweetLength("sample tweet"), 12, "small tweet should be counted correctly.");
equal(twttr.txt.getTweetLength("sample tweet with short url http://t.co/1"), 51, "Should count short URLs as 23");
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");

// With override configs
equal(twttr.txt.getTweetLength("sample tweet", config), 12, "small tweet should be counted correctly with config");
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");
});

test("twttr.txt.parseTweet", function() {
var configVersion1 = twttr.txt.configs.version1;
var configVersion2 = twttr.txt.configs.version2;
Expand Down

0 comments on commit 752b947

Please sign in to comment.