Fix markdown images having duplicate ids (#157177)

Fixes #153144
This commit is contained in:
Matt Bierner
2022-08-04 21:31:42 -07:00
committed by GitHub
parent 5589b81019
commit b012216211
5 changed files with 20 additions and 42 deletions

View File

@@ -1,16 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
function numberHash(val: number, initialHashVal: number): number {
return (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32
}
export function stringHash(s: string) {
let hashVal = numberHash(149417, 0);
for (let i = 0, length = s.length; i < length; i++) {
hashVal = numberHash(s.charCodeAt(i), hashVal);
}
return hashVal;
}