diff --git a/.changeset/shy-steaks-invite.md b/.changeset/shy-steaks-invite.md
new file mode 100644
index 0000000000..b4a70589f9
--- /dev/null
+++ b/.changeset/shy-steaks-invite.md
@@ -0,0 +1,16 @@
+---
+'@backstage/plugin-catalog-backend-module-bitbucket': patch
+'@backstage/plugin-catalog-backend-module-github': patch
+'@backstage/plugin-catalog-backend-module-gitlab': patch
+'@backstage/plugin-catalog-backend-module-azure': patch
+'@backstage/plugin-azure-devops-backend': patch
+'@backstage/plugin-git-release-manager': patch
+'@backstage/core-components': patch
+'@backstage/plugin-playlist-backend': patch
+'@backstage/plugin-apache-airflow': patch
+'@backstage/plugin-circleci': patch
+'@backstage/plugin-bitrise': patch
+'@backstage/plugin-sentry': patch
+---
+
+Internal refactor to not use deprecated `substr`
diff --git a/microsite/pages/en/on-demand.js b/microsite/pages/en/on-demand.js
index 41a730205b..15059e91a1 100644
--- a/microsite/pages/en/on-demand.js
+++ b/microsite/pages/en/on-demand.js
@@ -20,7 +20,7 @@ const ondemandMetadata = fs
.reverse()
.map(file => yaml.load(fs.readFileSync(`./data/on-demand/${file}`, 'utf8')));
const truncate = text =>
- text.length > 170 ? text.substr(0, 170) + '...' : text;
+ text.length > 170 ? text.slice(0, 170) + '...' : text;
const addVideoDocsLink = '/docs/overview/support';
const defaultIconUrl = 'img/logo-gradient-on-dark.svg';
diff --git a/microsite/pages/en/plugins.js b/microsite/pages/en/plugins.js
index 9a0a59bd4b..237161b98a 100644
--- a/microsite/pages/en/plugins.js
+++ b/microsite/pages/en/plugins.js
@@ -19,7 +19,7 @@ const pluginMetadata = fs
.map(file => yaml.load(fs.readFileSync(`./data/plugins/${file}`, 'utf8')))
.sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()));
const truncate = text =>
- text.length > 170 ? text.substr(0, 170) + '...' : text;
+ text.length > 170 ? text.slice(0, 170) + '...' : text;
const newForDays = 100;
diff --git a/packages/core-components/src/components/Avatar/utils.ts b/packages/core-components/src/components/Avatar/utils.ts
index d8310f18c0..4f71d736f1 100644
--- a/packages/core-components/src/components/Avatar/utils.ts
+++ b/packages/core-components/src/components/Avatar/utils.ts
@@ -22,11 +22,11 @@ export function stringToColor(str: string) {
let color = '#';
for (let i = 0; i < 3; i++) {
const value = (hash >> (i * 8)) & 0xff;
- color += `00${value.toString(16)}`.substr(-2);
+ color += `00${value.toString(16)}`.slice(-2);
}
return color;
}
export function extractInitials(value: string) {
- return value.match(/\b\w/g)?.join('').substring(0, 2);
+ return value.match(/\b\w/g)?.join('').slice(0, 2);
}
diff --git a/plugins/apache-airflow/src/components/ScheduleIntervalLabel/ScheduleIntervalLabel.tsx b/plugins/apache-airflow/src/components/ScheduleIntervalLabel/ScheduleIntervalLabel.tsx
index 14e8148b50..7bd8445766 100644
--- a/plugins/apache-airflow/src/components/ScheduleIntervalLabel/ScheduleIntervalLabel.tsx
+++ b/plugins/apache-airflow/src/components/ScheduleIntervalLabel/ScheduleIntervalLabel.tsx
@@ -26,7 +26,7 @@ const timeDeltaToLabel = (delta: TimeDelta): string => {
let label = '';
const date = new Date(0);
date.setSeconds(delta.seconds);
- const time = date.toISOString().substr(11, 8);
+ const time = date.toISOString().slice(11, 11 + 8);
if (delta.days === 0) {
label = `${time}`;
} else if (delta.days === 1) {
diff --git a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts
index 24c13020b6..87ded2f0e9 100644
--- a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts
+++ b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts
@@ -434,7 +434,7 @@ export function mappedRepoBuild(build: Build): RepoBuild {
queueTime: build.queueTime?.toISOString(),
startTime: build.startTime?.toISOString(),
finishTime: build.finishTime?.toISOString(),
- source: `${build.sourceBranch} (${build.sourceVersion?.substr(0, 8)})`,
+ source: `${build.sourceBranch} (${build.sourceVersion?.slice(0, 8)})`,
uniqueName: build.requestedFor?.uniqueName ?? 'N/A',
};
}
@@ -489,7 +489,7 @@ export function mappedBuildRun(build: Build): BuildRun {
queueTime: build.queueTime?.toISOString(),
startTime: build.startTime?.toISOString(),
finishTime: build.finishTime?.toISOString(),
- source: `${build.sourceBranch} (${build.sourceVersion?.substr(0, 8)})`,
+ source: `${build.sourceBranch} (${build.sourceVersion?.slice(0, 8)})`,
uniqueName: build.requestedFor?.uniqueName ?? 'N/A',
};
}
diff --git a/plugins/bitrise/src/components/BitriseBuildsTableComponent/BitriseBuildsTableComponent.tsx b/plugins/bitrise/src/components/BitriseBuildsTableComponent/BitriseBuildsTableComponent.tsx
index 0966de3377..3f6ebf93f4 100644
--- a/plugins/bitrise/src/components/BitriseBuildsTableComponent/BitriseBuildsTableComponent.tsx
+++ b/plugins/bitrise/src/components/BitriseBuildsTableComponent/BitriseBuildsTableComponent.tsx
@@ -81,7 +81,7 @@ const renderSource = (build: BitriseBuildResult): React.ReactNode => {
rel="noreferrer"
startIcon={}
>
- {build.commitHash.substr(0, 6)}
+ {build.commitHash.slice(0, 6)}
) : null;
};
diff --git a/plugins/catalog-backend-module-azure/src/processors/AzureDevOpsDiscoveryProcessor.ts b/plugins/catalog-backend-module-azure/src/processors/AzureDevOpsDiscoveryProcessor.ts
index ad63fef810..4852edbb03 100644
--- a/plugins/catalog-backend-module-azure/src/processors/AzureDevOpsDiscoveryProcessor.ts
+++ b/plugins/catalog-backend-module-azure/src/processors/AzureDevOpsDiscoveryProcessor.ts
@@ -132,7 +132,7 @@ export function parseUrl(urlString: string): {
catalogPath: string;
} {
const url = new URL(urlString);
- const path = url.pathname.substr(1).split('/');
+ const path = url.pathname.slice(1).split('/');
const catalogPath = url.searchParams.get('path') || '/catalog-info.yaml';
diff --git a/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.ts b/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.ts
index 6924765483..78aa3eacfd 100644
--- a/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.ts
+++ b/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.ts
@@ -342,7 +342,7 @@ function parseUrl(urlString: string): {
const url = new URL(urlString);
const indexOfProjectSegment =
url.pathname.toLowerCase().indexOf('/projects/') + 1;
- const path = url.pathname.substr(indexOfProjectSegment).split('/');
+ const path = url.pathname.slice(indexOfProjectSegment).split('/');
// /projects/backstage/repos/techdocs-*/catalog-info.yaml
if (path.length > 3 && path[1].length && path[3].length) {
@@ -373,7 +373,7 @@ function parseBitbucketCloudUrl(urlString: string): {
searchEnabled: boolean;
} {
const url = new URL(urlString);
- const pathMap = readPathParameters(url.pathname.substr(1).split('/'));
+ const pathMap = readPathParameters(url.pathname.slice(1).split('/'));
const query = url.searchParams;
if (!pathMap.has('workspaces')) {
diff --git a/plugins/catalog-backend-module-github/src/lib/util.ts b/plugins/catalog-backend-module-github/src/lib/util.ts
index ece463bb40..967a3231b6 100644
--- a/plugins/catalog-backend-module-github/src/lib/util.ts
+++ b/plugins/catalog-backend-module-github/src/lib/util.ts
@@ -17,7 +17,7 @@
import { GithubTopicFilters } from '../providers/GithubEntityProviderConfig';
export function parseGithubOrgUrl(urlString: string): { org: string } {
- const path = new URL(urlString).pathname.substr(1).split('/');
+ const path = new URL(urlString).pathname.slice(1).split('/');
// /backstage
if (path.length === 1 && path[0].length) {
diff --git a/plugins/catalog-backend-module-github/src/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend-module-github/src/processors/GithubDiscoveryProcessor.ts
index 593f5f72f1..3fec87d0b2 100644
--- a/plugins/catalog-backend-module-github/src/processors/GithubDiscoveryProcessor.ts
+++ b/plugins/catalog-backend-module-github/src/processors/GithubDiscoveryProcessor.ts
@@ -176,7 +176,7 @@ export function parseUrl(urlString: string): {
host: string;
} {
const url = new URL(urlString);
- const path = url.pathname.substr(1).split('/');
+ const path = url.pathname.slice(1).split('/');
// /backstage/techdocs-*/blob/master/catalog-info.yaml
// can also be
diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts
index 1344e2f5d1..01cb701d46 100644
--- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts
+++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts
@@ -423,7 +423,7 @@ export function parseUrl(urlString: string): {
host: string;
} {
const url = new URL(urlString);
- const path = url.pathname.substr(1).split('/');
+ const path = url.pathname.slice(1).split('/');
// /backstage/techdocs-*/blob/master/catalog-info.yaml
// can also be
diff --git a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts
index b03c665ebc..756093bc56 100644
--- a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts
+++ b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts
@@ -193,7 +193,7 @@ export function parseUrl(urlString: string): {
catalogPath: string;
} {
const url = new URL(urlString);
- const path = url.pathname.substr(1).split('/');
+ const path = url.pathname.slice(1).split('/');
// (/group/subgroup)/blob/branch|*/filepath
const blobIndex = path.findIndex(p => p === 'blob');
diff --git a/plugins/circleci/src/state/useBuilds.ts b/plugins/circleci/src/state/useBuilds.ts
index 760c57d764..1e199cfd34 100644
--- a/plugins/circleci/src/state/useBuilds.ts
+++ b/plugins/circleci/src/state/useBuilds.ts
@@ -64,7 +64,7 @@ const mapSourceDetails = (buildData: BuildSummary) => {
branchName: String(buildData.branch),
commit: {
hash: String(buildData.vcs_revision),
- shortHash: String(buildData.vcs_revision).substr(0, 7),
+ shortHash: String(buildData.vcs_revision).slice(0, 7),
committerName: buildData.committer_name,
url: commitDetails.commit_url,
},
diff --git a/plugins/git-release-manager/src/helpers/getShortCommitHash.ts b/plugins/git-release-manager/src/helpers/getShortCommitHash.ts
index fd53ac7941..3b7a9cc310 100644
--- a/plugins/git-release-manager/src/helpers/getShortCommitHash.ts
+++ b/plugins/git-release-manager/src/helpers/getShortCommitHash.ts
@@ -17,7 +17,7 @@
import { GitReleaseManagerError } from '../errors/GitReleaseManagerError';
export function getShortCommitHash(hash: string) {
- const shortCommitHash = hash.substr(0, 7);
+ const shortCommitHash = hash.slice(0, 7);
if (shortCommitHash.length < 7) {
throw new GitReleaseManagerError(
diff --git a/plugins/playlist-backend/src/service/ListPlaylistsFilter.ts b/plugins/playlist-backend/src/service/ListPlaylistsFilter.ts
index a746286136..680f389f8c 100644
--- a/plugins/playlist-backend/src/service/ListPlaylistsFilter.ts
+++ b/plugins/playlist-backend/src/service/ListPlaylistsFilter.ts
@@ -79,9 +79,9 @@ export function parseListPlaylistsFilterString(
const equalsIndex = statement.indexOf('=');
const key =
- equalsIndex === -1 ? statement : statement.substr(0, equalsIndex).trim();
+ equalsIndex === -1 ? statement : statement.slice(0, equalsIndex).trim();
const value =
- equalsIndex === -1 ? undefined : statement.substr(equalsIndex + 1).trim();
+ equalsIndex === -1 ? undefined : statement.slice(equalsIndex + 1).trim();
if (!key || !value) {
throw new InputError(
diff --git a/plugins/search-backend-module-pg/src/database/util.test.ts b/plugins/search-backend-module-pg/src/database/util.test.ts
index 09eb70c096..b3df5a3ad4 100644
--- a/plugins/search-backend-module-pg/src/database/util.test.ts
+++ b/plugins/search-backend-module-pg/src/database/util.test.ts
@@ -50,7 +50,7 @@ describe('util', () => {
'should get postgres major version, %p',
async databaseId => {
const knex = await databases.init(databaseId);
- const expectedVersion = +databaseId.substr(9);
+ const expectedVersion = +databaseId.slice(9);
await expect(queryPostgresMajorVersion(knex)).resolves.toBe(
expectedVersion,
diff --git a/plugins/sentry/src/components/ErrorCell/ErrorCell.tsx b/plugins/sentry/src/components/ErrorCell/ErrorCell.tsx
index 015cf96ed1..14e0213bfa 100644
--- a/plugins/sentry/src/components/ErrorCell/ErrorCell.tsx
+++ b/plugins/sentry/src/components/ErrorCell/ErrorCell.tsx
@@ -22,7 +22,7 @@ import { BackstageTheme } from '@backstage/theme';
import { Link } from '@backstage/core-components';
function stripText(text: string, maxLength: number) {
- return text.length > maxLength ? `${text.substr(0, maxLength)}...` : text;
+ return text.length > maxLength ? `${text.slice(0, maxLength)}...` : text;
}
const useStyles = makeStyles(theme => ({
root: {