Skip to content
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

URL without host should not fails canIncludeCorrelationHeader right away #1583

Merged
merged 2 commits into from
Jun 17, 2021

Conversation

xiao-lix
Copy link
Contributor

@xiao-lix xiao-lix requested a review from MSNev June 17, 2021 00:27
@@ -65,7 +65,7 @@ export function urlGetCompleteUrl(method: string, absoluteUrl: string) {

// Fallback method to grab host from url if document.createElement method is not available
export function urlParseHost(url: string, inclPort?: boolean) {
let fullHost = urlParseFullHost(url, inclPort);
let fullHost = urlParseFullHost(url, inclPort) || "";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add | "" means when url has no host, the urlParseFullHost method returns null. In that case, null passed back to here but null.toLowerCase() is wrong. So always return an empty string when host is not detected.

@@ -238,9 +238,9 @@ export interface IUtil {

export const Util: IUtil = {
NotSpecified: strNotSpecified,
createDomEvent: createDomEvent,
createDomEvent,
Copy link
Contributor Author

@xiao-lix xiao-lix Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix some ts-lint errors

@@ -355,7 +355,7 @@ export const CorrelationIdHelper: ICorrelationIdHelper = {
requestHost = (urlParseFullHost(requestUrl, true) || "").toLowerCase();
}

if ((!config || !config.enableCorsCorrelation) && requestHost !== currentHost) {
if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONLY check if the requestHost equals currentHost when requestHost exists. For the case that requestHost not exist (empty string when host not exist) skip the check. Otherwise it will returns false right away for the cases that url without host.

@MSNev MSNev added this to the 2.x.x (Next Release) milestone Jun 17, 2021
@xiao-lix xiao-lix merged commit f2bab23 into master Jun 17, 2021
@MSNev MSNev deleted the lxiao/bug-corr-header branch August 4, 2021 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants