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

[CLEANUP beta] Replace deprecated substr() method with substring() method #20125

Merged
merged 1 commit into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@ember/-internals/metal/lib/chain-tags.ts
Expand Up @@ -182,7 +182,7 @@ function getChainTags(
} else {
// use metaFor here to ensure we have the meta for the instance
let lazyChains = instanceMeta.writableLazyChainsFor(segment);
let rest = path.substr(segmentEnd + 1);
let rest = path.substring(segmentEnd + 1);

let placeholderTag = createUpdatableTag();

Expand Down
10 changes: 5 additions & 5 deletions packages/@ember/-internals/routing/lib/location/auto_location.ts
Expand Up @@ -275,7 +275,7 @@ function detectImplementation(options: DetectionOptions) {
// the history location with no redirects.
if (currentPath === historyPath) {
implementation = 'history';
} else if (currentPath.substr(0, 2) === '/#') {
} else if (currentPath.substring(0, 2) === '/#') {
history.replaceState({ path: historyPath }, '', historyPath);
implementation = 'history';
} else {
Expand Down Expand Up @@ -326,16 +326,16 @@ export function getHistoryPath(rootURL: string, location: Location): string {
// By convention, Ember.js routes using HashLocation are required to start
// with `#/`. Anything else should NOT be considered a route and should
// be passed straight through, without transformation.
if (hash.substr(0, 2) === '#/') {
if (hash.substring(0, 2) === '#/') {
// There could be extra hash segments after the route
hashParts = hash.substr(1).split('#');
hashParts = hash.substring(1).split('#');
// The first one is always the route url
routeHash = hashParts.shift() as string;

// If the path already has a trailing slash, remove the one
// from the hashed route so we don't double up.
if (path.charAt(path.length - 1) === '/') {
routeHash = routeHash.substr(1);
routeHash = routeHash.substring(1);
}

// This is the "expected" final order
Expand All @@ -362,7 +362,7 @@ export function getHistoryPath(rootURL: string, location: Location): string {
export function getHashPath(rootURL: string, location: Location): string {
let path = rootURL;
let historyPath = getHistoryPath(rootURL, location);
let routePath = historyPath.substr(rootURL.length);
let routePath = historyPath.substring(rootURL.length);

if (routePath !== '') {
if (routePath[0] !== '/') {
Expand Down
Expand Up @@ -72,7 +72,7 @@ export default class HashLocation extends EmberObject implements EmberLocation {
@method getURL
*/
getURL(): string {
let originalPath = this.getHash().substr(1);
let originalPath = this.getHash().substring(1);
let outPath = originalPath;

if (outPath[0] !== '/') {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/location/util.ts
Expand Up @@ -29,7 +29,7 @@ export function getQuery(location: Location): string {
*/
export function getHash(location: Location): string {
if (location.hash !== undefined) {
return location.hash.substr(0);
return location.hash.substring(0);
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/services/router.ts
Expand Up @@ -18,7 +18,7 @@ function cleanURL(url: string, rootURL: string) {
return url;
}

return url.substr(rootURL.length, url.length);
return url.substring(rootURL.length);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/utils.ts
Expand Up @@ -153,7 +153,7 @@ export function calculateCacheKey(prefix: string, parts: string[] = [], values:
if (values) {
if (cacheValuePrefix && cacheValuePrefix in values) {
let partRemovedPrefix =
part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part;
part.indexOf(cacheValuePrefix) === 0 ? part.substring(cacheValuePrefix.length + 1) : part;
value = get((values as any)[cacheValuePrefix], partRemovedPrefix);
} else {
value = get(values, part);
Expand Down
Expand Up @@ -56,7 +56,7 @@ export default function assertAgainstAttrs(env: EmberASTPluginEnvironment): ASTP

PathExpression(node: AST.PathExpression): AST.Node | void {
if (isAttrs(node, stack[stack.length - 1]!)) {
let path = b.path(node.original.substr(6));
let path = b.path(node.original.substring(6));

assert(
`Using {{attrs}} to reference named arguments is not supported. {{attrs.${
Expand Down