Skip to content

Commit 9b79098

Browse files
Merge pull request #428 from GSA/lc/1325-update-redirect-field
1325 - Update Redirect Field
2 parents 134e800 + b57f65e commit 9b79098

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

libs/core-scanner/src/scans/url-scan.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ const getFinalUrl = (page: Page) => {
5050
return finalUrl;
5151
};
5252

53-
function cleanUrl(url: string): string {
54-
// Remove the protocol (http:// or https://)
55-
url = url.replace(/^https?:\/\//, '');
56-
57-
// Remove trailing slashes
58-
url = url.replace(/\/$/, '');
59-
60-
return url;
61-
}
62-
6353
function removeWww(url: string): string {
6454
return url.replace(/^www\./, '');
6555
}
@@ -68,7 +58,7 @@ function removeWww(url: string): string {
6858
* Compares the initial URL and final URL to determine if a redirect occurred
6959
*
7060
* @param initialUrl The initial URL that is being scanned. Stored as the `url` property in the CoreInputDto
71-
* @param finalUrl The final URL after all redirects. Stored as the `name` property in the CoreResult
61+
* @param finalUrl The final URL after all redirects. Stored as the `name` property in the CoreResult after removing www.
7262
* @param logger
7363
* @returns true if the initial URL and final URL are the same, false if they are different, and null if either is missing
7464
*/
@@ -78,16 +68,15 @@ function isRedirect(initialUrl: string, finalUrl: string, logger: Logger): boole
7868
return null;
7969
}
8070

81-
initialUrl = cleanUrl(initialUrl);
82-
finalUrl = removeWww(cleanUrl(finalUrl));
71+
finalUrl = removeWww(finalUrl);
8372

8473
if (initialUrl === finalUrl) {
8574
logger.info({redirectCheck: {initialUrl, finalUrl}}, 'Initial URL and final URL are the same.');
86-
return true;
75+
return false;
8776
}
8877
if (initialUrl && finalUrl) {
8978
logger.info({redirectCheck: {initialUrl, finalUrl}}, 'Initial URL and final URL are different.');
90-
return false;
79+
return true;
9180
}
9281

9382
return null;

0 commit comments

Comments
 (0)