From 8494f7275690e219656c4246c20d0a008532d407 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 10 Nov 2024 10:47:55 -0800 Subject: [PATCH] feat: add support for activities with unicode chars (#773) --- lib/helpers.js | 2 +- test/unit/helper-specs.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 729b0e10..35724fcb 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1005,7 +1005,7 @@ function parseLaunchableActivityNames (dumpsys) { */ function matchComponentName (classString) { // some.package/some.package.Activity - return /^[a-z0-9./_]+$/i.exec(classString); + return /^[\p{L}0-9./_]+$/u.exec(classString); } /** diff --git a/test/unit/helper-specs.js b/test/unit/helper-specs.js index d2c4d9d7..af16f054 100644 --- a/test/unit/helper-specs.js +++ b/test/unit/helper-specs.js @@ -2,7 +2,7 @@ import { getAndroidPlatformAndPath, buildStartCmd, isShowingLockscreen, getBuildToolsDirs, parseAaptStrings, parseAapt2Strings, - extractMatchingPermissions, parseLaunchableActivityNames, + extractMatchingPermissions, parseLaunchableActivityNames, matchComponentName, } from '../../lib/helpers'; import { withMocks } from '@appium/test-support'; import { fs } from '@appium/support'; @@ -480,4 +480,16 @@ describe('helpers', withMocks({fs}, function (mocks) { names.should.be.eql([]); }); }); + describe('matchComponentName', function () { + it('test valid activity name', function () { + const activity = 'ןذأצЮυπиС.נפשוקשΤπΟ.ЦοКسئοهΦΦ'; + const names = matchComponentName(activity); + names.should.eql([activity]); + }); + it('test invalid activity name', function () { + const activity = 'User@123'; + _.isNull(matchComponentName(activity)).should.be.true; + }); + + }); }));