mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-19 21:51:16 -06:00
* server: fix runaway regexp fails parsing a massive JS file * server: fix linting errors, better debug logs * server: lint fix again
27 lines
842 B
CoffeeScript
27 lines
842 B
CoffeeScript
stream = require("stream")
|
|
pumpify = require("pumpify")
|
|
replacestream = require("replacestream")
|
|
|
|
topOrParentEqualityBeforeRe = /((?:window|self)(?:\.|\[['"](?:top|self)['"]\])?\s*[!=][=]\s*(?:(?:window|self)(?:\.|\[['"]))?)(top|parent)/g
|
|
topOrParentEqualityAfterRe = /(top|parent)((?:["']\])?\s*[!=][=].*(?:window|self))/g
|
|
topOrParentLocationOrFramesRe = /([^\da-zA-Z])(top|parent)([.])(location|frames)/g
|
|
|
|
strip = (html) ->
|
|
html
|
|
.replace(topOrParentEqualityBeforeRe, "$1self")
|
|
.replace(topOrParentEqualityAfterRe, "self$2")
|
|
.replace(topOrParentLocationOrFramesRe, "$1self$3$4")
|
|
|
|
stripStream = ->
|
|
pumpify(
|
|
replacestream(topOrParentEqualityBeforeRe, "$1self")
|
|
replacestream(topOrParentEqualityAfterRe, "self$2")
|
|
replacestream(topOrParentLocationOrFramesRe, "$1self$3$4")
|
|
)
|
|
|
|
module.exports = {
|
|
strip
|
|
|
|
stripStream
|
|
}
|