mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-05 22:19:46 -06:00
* chore(deps): Update eslint to 6.8.0 🌟 * fix missing dangling commas for linter * fix missing dangling commas for linter * more lint fixes * yarn lock Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com> Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
const pumpify = require('pumpify')
|
|
const { replaceStream } = require('./replace_stream')
|
|
const utf8Stream = require('utf8-stream')
|
|
|
|
const topOrParentEqualityBeforeRe = /((?:window|self)(?:\.|\[['"](?:top|self)['"]\])?\s*[!=]==?\s*(?:(?:window|self)(?:\.|\[['"]))?)(top|parent)(?![\w])/g
|
|
const topOrParentEqualityAfterRe = /(top|parent)((?:["']\])?\s*[!=]==?\s*(?:window|self))/g
|
|
const topOrParentLocationOrFramesRe = /([^\da-zA-Z\(\)])?(top|parent)([.])(location|frames)/g
|
|
const jiraTopWindowGetterRe = /(!function\s*\((\w{1})\)\s*{\s*return\s*\w{1}\s*(?:={2,})\s*\w{1}\.parent)(\s*}\(\w{1}\))/g
|
|
|
|
export function strip (html: string) {
|
|
return html
|
|
.replace(topOrParentEqualityBeforeRe, '$1self')
|
|
.replace(topOrParentEqualityAfterRe, 'self$2')
|
|
.replace(topOrParentLocationOrFramesRe, '$1self$3$4')
|
|
.replace(jiraTopWindowGetterRe, '$1 || $2.parent.__Cypress__$3')
|
|
}
|
|
|
|
export function stripStream () {
|
|
return pumpify(
|
|
utf8Stream(),
|
|
replaceStream(
|
|
[
|
|
topOrParentEqualityBeforeRe,
|
|
topOrParentEqualityAfterRe,
|
|
topOrParentLocationOrFramesRe,
|
|
jiraTopWindowGetterRe,
|
|
],
|
|
[
|
|
'$1self',
|
|
'self$2',
|
|
'$1self$3$4',
|
|
'$1 || $2.parent.__Cypress__$3',
|
|
],
|
|
),
|
|
)
|
|
}
|