Skip to content

Commit

Permalink
SSE event mixin: Replace RegEx lookbehind assertion with split by str…
Browse files Browse the repository at this point in the history
…ing (#2157)

Fixes #2153.
Regression from #2055.

MainUI was broken on older iOS versions, e.g. 15.8, because RegEx
lookbehind assertions were introduced with Safari 16.4.
This uses split by string instead and adds an ESLint rule to forbid
the usage of RegEx lookbehind assertions.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 authored Oct 30, 2023
1 parent 8f06d97 commit 6d71b3d
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 23 deletions.
4 changes: 3 additions & 1 deletion bundles/org.openhab.ui/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module.exports = {
'@babel',
'import',
'cypress',
'vue'
'vue',
'es'
],

globals: {
Expand Down Expand Up @@ -57,6 +58,7 @@ module.exports = {
'no-case-declarations': 'off',
'no-console': 'off',
'no-debugger': 'off',
'es/no-regexp-lookbehind-assertions': 'error', // Supported in Safari >= 16.4, which breaks iOS 15.x.
'no-trailing-spaces': 'error',
'no-unsafe-optional-chaining': 'error',
'no-whitespace-before-property': 'error',
Expand Down
119 changes: 101 additions & 18 deletions bundles/org.openhab.ui/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bundles/org.openhab.ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"diacritic": "0.0.2",
"eslint": "^7.19.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-vue": "^7.5.0",
Expand Down
8 changes: 4 additions & 4 deletions bundles/org.openhab.ui/web/src/components/sse-events-mixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OhPopup from './widgets/modals/oh-popup.vue'
import OhSheet from './widgets/modals/oh-sheet.vue'
import OhPopover from './widgets/modals/oh-popover.vue'
import OhPopup from '@/components/widgets/modals/oh-popup.vue'
import OhSheet from '@/components/widgets/modals/oh-sheet.vue'
import OhPopover from '@/components/widgets/modals/oh-popover.vue'

export default {
data () {
Expand Down Expand Up @@ -35,7 +35,7 @@ export default {
break
case topicCommand:
const payload = JSON.parse(event.payload)
const [command, ...segments] = payload.value.trim().split(/(?<!\\):/)
const [command, ...segments] = payload.value.trim().split(':') // NOT use a RegEx lookbehind assertions here, because they are unsupported on Safari < 16.4, i.e. iOS 15.x
const combined = segments.join(':')
switch (command) {
case 'navigate':
Expand Down

0 comments on commit 6d71b3d

Please sign in to comment.