mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-02 11:05:33 -05:00
[INS-3767](https://konghq.atlassian.net/browse/INS-3767) ## Summary - Remove scripting-environment imports from Insomnia application modules. - Move shared faker, URL helpers, and response reason data into appropriate insomnia-data modules. - Move certificate matching behavior and its test into the ClientCertificate model. - Update all callers and remove obsolete module paths. ## Verification - insomnia-data type-check and lint - insomnia-scripting-environment lint and tests - insomnia type-check - URL/certificate tests: 50 passed - circular-reference check: no new circular dependencies; insomnia-scripting-environment has 0 cycles The existing scripting-environment tsconfig is intentionally unchanged here; its source-wide type-check scope is enabled in the stacked sendRequest PR after the remaining Insomnia runtime dependency is removed.
22 lines
526 B
TypeScript
22 lines
526 B
TypeScript
/**
|
|
* Set a default protocol for a URL
|
|
* @param url URL to set protocol on
|
|
* @param [defaultProto='http:'] default protocol
|
|
*/
|
|
export const setDefaultProtocol = (url: string, defaultProto?: string) => {
|
|
const trimmedUrl = url.trim();
|
|
defaultProto = defaultProto || 'http:';
|
|
|
|
// If no url, don't bother returning anything
|
|
if (!trimmedUrl) {
|
|
return '';
|
|
}
|
|
|
|
// Default the proto if it doesn't exist
|
|
if (!trimmedUrl.includes('://')) {
|
|
return `${defaultProto}//${trimmedUrl}`;
|
|
}
|
|
|
|
return trimmedUrl;
|
|
};
|