Skip to content

Commit a5d3689

Browse files
Replace deprecated String.prototype.substr() (#311)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <[email protected]>
1 parent 66ba57f commit a5d3689

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ module.exports = {
5353
}
5454
],
5555
'node/no-deprecated-api': 'off',
56+
'no-restricted-properties': [
57+
'error',
58+
{ property: 'substr', message: 'Use .slice instead of .substr.' }
59+
],
5660
'node/no-unpublished-import': 'off',
5761
'node/no-unpublished-require': 'off',
5862
'node/no-unsupported-features/es-syntax': 'off',

packages/vite-plugin-svelte/src/utils/hash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function safeBase64Hash(input: string) {
1414
// OR DON'T USE A HASH AT ALL, what about a simple counter?
1515
const md5 = crypto.createHash('md5');
1616
md5.update(input);
17-
const hash = toSafe(md5.digest('base64')).substr(0, hash_length);
17+
const hash = toSafe(md5.digest('base64')).slice(0, hash_length);
1818
hashes[input] = hash;
1919
return hash;
2020
}

0 commit comments

Comments
 (0)