New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistencies in CYPRESS_DOWNLOAD_PATH_TEMPLATE handling #19914
Comments
backslash is very uncommon in URL. Would it be reasonable to escape backslash specifically for https://github.com/cypress-io/cypress/blob/v9.3.1/cli/lib/tasks/download.js#L69-L72 Proposal: const prepend = (urlPath) => {
const endpoint = Url.resolve(getBaseUrl(), urlPath)
const platform = os.platform()
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE')
return pathTemplate
- ? pathTemplate.replace('${endpoint}', endpoint).replace('${platform}', platform).replace('${arch}', arch())
+ ? pathTemplate.replace(/\\?\$\{endpoint\}/, endpoint).replace(/\\?\$\{platform\}/, platform).replace(/\\?\$\{arch\}/, arch())
: `${endpoint}?platform=${platform}&arch=${arch()}`
} Test snippetoutput = (pathTemplate) => {
const endpoint = 'endpoint';
const platform = 'platform';
const arch = () => 'arch';
const codeFn = () => {
return pathTemplate
? pathTemplate.replace(/\\?\$\{endpoint\}/, endpoint).replace(/\\?\$\{platform\}/, platform).replace(/\\?\$\{arch\}/, arch())
: `${endpoint}?platform=${platform}&arch=${arch()}`;
};
console.log(`input : ${pathTemplate}`);
console.log(`output: ${codeFn()}`);
};
output("\\${endpoint}/\\${platform}-\\${arch}/cypress.zip");
// input : \${endpoint}/\${platform}-\${arch}/cypress.zip
// output: endpoint/platform-arch/cypress.zip
output("${endpoint}/${platform}-${arch}/cypress.zip");
// input : ${endpoint}/${platform}-${arch}/cypress.zip
// output: endpoint/platform-arch/cypress.zip |
I have done additional research in Windows 10 comparing the behaviour for
* I am not sure how I can test yarn2 or yarn 3 yet. From the findings above, cypress will need to be able to handle
|
The code for this is done in cypress-io/cypress#20698, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
There seem to be some inconsistencies in how CYPRESS_DOWNLOAD_PATH_TEMPLATE is handled from the .npmrc file depending on package manager and version.
Given
CYPRESS_DOWNLOAD_PATH_TEMPLATE=${endpoint}/${platform}-${arch}/cypress.zip
npm 7 works, though locally i've seen the env fail to get picked up because of casing.
npm 6 attempts to replay endpoint etc with other ENVs (this is unfortunate, but you can escape them but that doesn't work either)
Yarn 1 doesn't remove double quotes.
I haven't tested yarn 3 or npm 8 but they should be looked at, as well as windows useage.
Desired behavior
Ideally you could set the CYPRESS_DOWNLOAD_PATH_TEMPLATE variable with any package manager
Test code to reproduce
Try out setting variations of
Cypress Version
9.3.1
Other
Where CYPRESS_DOWNLOAD_PATH_TEMPLATE is used
https://github.com/cypress-io/cypress/blob/develop/cli/lib/tasks/download.js#L67
getEnv implementation
https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L459
We should probably be setting trim on getENV, that should resolve any double quotes problems.
The text was updated successfully, but these errors were encountered: