mirror of
https://github.com/hanzoai/Detox.git
synced 2026-09-24 16:55:12 +00:00
fix: sanitize dollar sign in artifact names (#4820)
This commit is contained in:
committed by
GitHub
parent
679c850e64
commit
ddc5436f5b
+1
-1
@@ -68,7 +68,7 @@
|
||||
"wtfnode": "^0.9.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wix-pilot/core": "^3.4.1",
|
||||
"@wix-pilot/core": "^3.4.2",
|
||||
"@wix-pilot/detox": "^1.0.13",
|
||||
"ajv": "^8.6.3",
|
||||
"bunyan": "^1.8.12",
|
||||
|
||||
@@ -41,7 +41,8 @@ function constructSafeFilename(prefix = '', trimmable = '', suffix = '') {
|
||||
|
||||
const trimmed = trimmable.slice(-MAX_FILE_LENGTH + nonTrimmableLength);
|
||||
const unsafe = prefix + trimmed + suffix;
|
||||
const sanitized = sanitize(unsafe, sanitizeOptions);
|
||||
const sanitized = sanitize(unsafe, sanitizeOptions)
|
||||
.replace(/\$/g, sanitizeOptions.replacement);
|
||||
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@ describe('constructSafeFilename', () => {
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
|
||||
it('should replace $ with _', () => {
|
||||
const actual = constructSafeFilename('', '1$2', '');
|
||||
const expected = '1_2';
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
|
||||
it('should throw exception when non-trimmable prefix and suffix occupy too much space', () => {
|
||||
expect(() => constructSafeFilename('0'.repeat(127), '1', '2'.repeat(128))).toThrow();
|
||||
});
|
||||
|
||||
@@ -59,7 +59,11 @@ module.exports = async () => {
|
||||
'eventListeners': [
|
||||
'jest-metadata/environment-listener',
|
||||
'jest-allure2-reporter/environment-listener',
|
||||
require.resolve('detox-allure2-adapter'),
|
||||
[require.resolve('detox-allure2-adapter'), {
|
||||
deviceLogs: true,
|
||||
deviceScreenshots: true,
|
||||
deviceVideos: false,
|
||||
}],
|
||||
require.resolve('./utils/rnSkipper'),
|
||||
]
|
||||
},
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"axios": "^1.7.7",
|
||||
"cross-env": "^7.0.3",
|
||||
"detox": "^20.41.3",
|
||||
"detox-allure2-adapter": "^1.0.0-alpha.8",
|
||||
"detox-allure2-adapter": "1.0.0-alpha.29",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-unicorn": "^50.0.1",
|
||||
"execa": "^5.1.1",
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
function template({ title = 'iframe viewer', url }) {
|
||||
return `\
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${title}</title>
|
||||
<style>
|
||||
html, body, iframe {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
border: none;
|
||||
}
|
||||
iframe {
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="${url}" frameborder="0" allowfullscreen></iframe>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
}
|
||||
|
||||
process.stdout.write(template({ url: process.argv[2], title: process.argv[3] }));
|
||||
@@ -0,0 +1,48 @@
|
||||
function template({ title = 'redirect page', url }) {
|
||||
return `\
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="refresh" content="0; url=${url}">
|
||||
<title>${title}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.redirect-message {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.loading {
|
||||
color: #666;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="redirect-message">
|
||||
<h2>Redirecting...</h2>
|
||||
<p>You will be redirected to the requested page shortly.</p>
|
||||
<p class="loading">If you are not redirected automatically, <a href="${url}">click here</a>.</p>
|
||||
</div>
|
||||
<script>
|
||||
// Client-side JavaScript fallback redirect
|
||||
setTimeout(function() {
|
||||
window.location.href = "${url}";
|
||||
}, 100);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
}
|
||||
|
||||
process.stdout.write(template({ url: process.argv[2], title: process.argv[3] }));
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
DATE=`date '+%Y-%m-%d_%H-%M-%S'`
|
||||
SCRIPTS_DIR=$(dirname "$0")
|
||||
GENERATE_IFRAME="$(readlink -f "${SCRIPTS_DIR}/create_iframe_html.js")"
|
||||
GENERATE_REDIRECT="$(readlink -f "${SCRIPTS_DIR}/create_redirect_html.js")"
|
||||
|
||||
pack() {
|
||||
local BASE_NAME=$1
|
||||
@@ -21,20 +21,20 @@ pack() {
|
||||
fi
|
||||
}
|
||||
|
||||
generate_iframe() {
|
||||
node "${GENERATE_IFRAME}" "$@"
|
||||
generate_redirect() {
|
||||
node "${GENERATE_REDIRECT}" "$@"
|
||||
}
|
||||
|
||||
upload_to_surge() {
|
||||
local TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
||||
local SURGE_PROJECT=$1
|
||||
local IFRAME_TITLE=$2
|
||||
local REDIRECT_TITLE=$2
|
||||
local SURGE_SUBDOMAIN="${SURGE_PROJECT}-${TIMESTAMP}"
|
||||
local SURGE_DOMAIN="${SURGE_SUBDOMAIN}.surge.sh"
|
||||
|
||||
if [ -d "${SURGE_PROJECT}" ]; then
|
||||
surge --domain "${SURGE_DOMAIN}" --project "${SURGE_PROJECT}" && \
|
||||
generate_iframe>>"${SURGE_SUBDOMAIN}.html" "https://${SURGE_DOMAIN}" "${IFRAME_TITLE}"
|
||||
generate_redirect>>"${SURGE_SUBDOMAIN}.html" "https://${SURGE_DOMAIN}" "${REDIRECT_TITLE}"
|
||||
else
|
||||
echo "Could not find directory named ${SURGE_PROJECT}."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user