Skip to content

Conversation

gofr
Copy link

@gofr gofr commented Sep 4, 2025

Summary

String slicing and indexing treats strings as sequences of UTF-16 code units. That makes diffStrings() break apart surrogate pairs.

Turn the strings to diff into arrays of code points to avoid that.

Test plan

Add a test for a surrogate pair. And also add tests for some other Unicode text segmentation edge cases for completeness.

Copy link

netlify bot commented Sep 4, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2932e57
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/68b96d0dad091800085a3054
😎 Deploy Preview https://deploy-preview-15812--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

linux-foundation-easycla bot commented Sep 4, 2025

CLA Not Signed

String slicing and indexing treats strings as sequences of UTF-16 code
units. That makes diffStrings() break apart surrogate pairs.

Turn the strings to diff into arrays of code points to avoid that.

Add tests also for some other Unicode text segmentation edge cases.
@gofr gofr force-pushed the support-surrogates-in-diffStrings branch from 2df29f8 to 2932e57 Compare September 4, 2025 10:42
Copy link

pkg-pr-new bot commented Sep 4, 2025

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15812

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15812

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15812

create-jest

npm i https://pkg.pr.new/create-jest@15812

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15812

expect

npm i https://pkg.pr.new/expect@15812

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15812

jest

npm i https://pkg.pr.new/jest@15812

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15812

jest-circus

npm i https://pkg.pr.new/jest-circus@15812

jest-cli

npm i https://pkg.pr.new/jest-cli@15812

jest-config

npm i https://pkg.pr.new/jest-config@15812

@jest/console

npm i https://pkg.pr.new/@jest/console@15812

@jest/core

npm i https://pkg.pr.new/@jest/core@15812

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15812

jest-diff

npm i https://pkg.pr.new/jest-diff@15812

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15812

jest-each

npm i https://pkg.pr.new/jest-each@15812

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15812

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15812

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15812

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15812

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15812

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15812

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15812

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15812

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15812

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15812

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15812

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15812

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15812

jest-mock

npm i https://pkg.pr.new/jest-mock@15812

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15812

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15812

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15812

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15812

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15812

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15812

jest-runner

npm i https://pkg.pr.new/jest-runner@15812

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15812

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15812

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15812

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15812

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15812

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15812

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15812

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15812

@jest/types

npm i https://pkg.pr.new/@jest/types@15812

jest-util

npm i https://pkg.pr.new/jest-util@15812

jest-validate

npm i https://pkg.pr.new/jest-validate@15812

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15812

jest-worker

npm i https://pkg.pr.new/jest-worker@15812

pretty-format

npm i https://pkg.pr.new/pretty-format@15812

commit: 2932e57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant