Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace deprecated String.prototype.substr() #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function PricingPlanBlock(props: PricingPlanBlockProps) {

const priceLabelCents =
_priceLabel[_priceLabel.length - 3] === '.'
? _priceLabel.substr(-3)
? _priceLabel.slice(-3)
: undefined
const priceLabelWithoutCents =
priceLabelCents && _priceLabel.endsWith(priceLabelCents)
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/cards/BaseCard.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ function _getCardPropsForItem(
actionTextOptions,
)
const actionText = `${_actionText
.substr(0, 1)
.toLowerCase()}${_actionText.substr(1)}`
.slice(0, 1)
.toLowerCase()}${_actionText.slice(1)}`

const iconDetails = getEventIconAndColor(event)
const icon = iconDetails as IconProp
Expand Down Expand Up @@ -1330,8 +1330,8 @@ export function getCardPushNotificationItem(
} = getEventMetadata(event, actionTextOptions)

const actionText = `${_actionText
.substr(0, 1)
.toLowerCase()}${_actionText.substr(1)}`
.slice(0, 1)
.toLowerCase()}${_actionText.slice(1)}`

const actorUsername = actor.display_login || actor.login

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function PricingPlanBlock(props: PricingPlanBlockProps) {
: _priceLabel
const priceLabelCents =
_cents && _priceLabel.endsWith(_cents.toString())
? _priceLabel.substr(-3)
? _priceLabel.slice(-3)
: ''

let footerText = ''
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/libs/analytics/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const analytics: Analytics = {
ga('send', 'event', {
eventCategory: hideTokenFromString(category),
eventAction: hideTokenFromString(action),
eventLabel: hideTokenFromString(label || '')!.substr(0, 100),
eventLabel: hideTokenFromString(label || '')!.slice(0, 100),
eventValue: value,
})
},
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/libs/analytics/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const analytics: Analytics = {
.analytics()
.logEvent(hideTokenFromString(action || '').replace(/\//g, '_'), {
event_category: hideTokenFromString(category),
event_label: hideTokenFromString(label || '').substr(0, 100),
event_label: hideTokenFromString(label || '').slice(0, 100),
value,
})
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/helpers/github/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export async function getNotificationsEnhancementMap(
const commentCache = cache.get(notification.subject.latest_comment_url)

const subjectField = (notification.subject.type[0].toLowerCase() +
notification.subject.type.substr(
notification.subject.type.slice(
1,
)) as keyof NotificationPayloadEnhancement

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/helpers/github/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function getCommitCompareUrlFromUrls(
const sha2 = getCommitShaFromUrl(commit2URL)
if (!(sha1 && sha2)) return

return `${repo1URL}/compare/${sha1.substr(0, 7)}...${sha2.substr(0, 7)}`
return `${repo1URL}/compare/${sha1.slice(0, 7)}...${sha2.slice(0, 7)}`
}

export function getCommitCompareUrlFromRefs(
Expand All @@ -61,7 +61,7 @@ export function getCommitCompareUrlFromRefs(
): string | undefined {
if (!(before && head && repoURL)) return

return `${repoURL}/compare/${before.substr(0, 7)}...${head.substr(0, 7)}`
return `${repoURL}/compare/${before.slice(0, 7)}...${head.slice(0, 7)}`
}

export function getIssueOrPullRequestNumberFromUrl(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/helpers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function trimNewLinesAndSpaces(text?: string, maxLength = 120) {

let newText = text.replace(/\s+/g, ' ').trim()
if (maxLength > 0 && newText.length > maxLength) {
newText = `${newText.substr(0, maxLength).trim()}...`
newText = `${newText.slice(0, maxLength).trim()}...`
}

return newText
Expand Down
2 changes: 1 addition & 1 deletion subdomains/www/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = (req, res) => {
res.statusCode = 301
res.setHeader('Location', `https://devhubapp.com/${req.url.substr(1)}`)
res.setHeader('Location', `https://devhubapp.com/${req.url.slice(1)}`)

res.end()
}