From 0ec695e036dab45d57598f451266bd0b176df9fd Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Mon, 4 Apr 2022 18:19:45 +0200 Subject: Replace deprecated String.prototype.substr() (#17949) * Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated * Change String.prototype.substring() to String.prototype.slice() .substring() and .slice() work very similary but .slice() is a bit faster and stricter * Add ESLint rule to forbid usage of .substr and .substring .substr() is deprecated and .substring() is very similar to .slice() so better to use .slice() at all times Signed-off-by: Tobias Speicher --- app/javascript/mastodon/features/emoji/emoji_mart_search_light.js | 2 +- app/javascript/mastodon/features/status/components/card.js | 2 +- app/javascript/mastodon/features/video/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/emoji/emoji_mart_search_light.js b/app/javascript/mastodon/features/emoji/emoji_mart_search_light.js index e4519a13e..70694ab6d 100644 --- a/app/javascript/mastodon/features/emoji/emoji_mart_search_light.js +++ b/app/javascript/mastodon/features/emoji/emoji_mart_search_light.js @@ -124,7 +124,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo for (let id in aPool) { let emoji = aPool[id], { search } = emoji, - sub = value.substr(0, length), + sub = value.slice(0, length), subIndex = search.indexOf(sub); if (subIndex !== -1) { diff --git a/app/javascript/mastodon/features/status/components/card.js b/app/javascript/mastodon/features/status/components/card.js index 90f9ae7ae..3d81bcb29 100644 --- a/app/javascript/mastodon/features/status/components/card.js +++ b/app/javascript/mastodon/features/status/components/card.js @@ -32,7 +32,7 @@ const trim = (text, len) => { return text; } - return text.substring(0, cut) + (text.length > len ? '…' : ''); + return text.slice(0, cut) + (text.length > len ? '…' : ''); }; const domParser = new DOMParser(); diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index 8d47e479a..4f90e955f 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -91,7 +91,7 @@ export const fileNameFromURL = str => { const pathname = url.pathname; const index = pathname.lastIndexOf('/'); - return pathname.substring(index + 1); + return pathname.slice(index + 1); }; export default @injectIntl -- cgit From 275dad97024d010853d995350b5224c0a3edc400 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Tue, 5 Apr 2022 19:00:31 +0900 Subject: fix: returns nil instead of empty URL on status.application.website (#17962) --- app/serializers/rest/status_serializer.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 32c4e405e..6bd6a23e5 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -137,6 +137,10 @@ class REST::StatusSerializer < ActiveModel::Serializer class ApplicationSerializer < ActiveModel::Serializer attributes :name, :website + + def website + object.website.presence + end end class MentionSerializer < ActiveModel::Serializer -- cgit