diff --git a/src/tools/safelink-decoder/safelink-decoder.service.ts b/src/tools/safelink-decoder/safelink-decoder.service.ts index 8653b963..2b94bcd8 100644 --- a/src/tools/safelink-decoder/safelink-decoder.service.ts +++ b/src/tools/safelink-decoder/safelink-decoder.service.ts @@ -1,28 +1,3 @@ export function decodeSafeLinksURL(safeLinksUrl: string) { - // Decode the ATP SafeLinks URL - let originalURL; - - try { - // Decode the URL - originalURL = decodeURIComponent(safeLinksUrl); - - // Check if it matches the SafeLinks pattern - if (originalURL.match(/\.safelinks\.protection\.outlook\.com\/\?url=.+&data=/)) { - // Extract the original URL - originalURL = originalURL.split('?url=')[1].split('&data=')[0]; - } - else if (originalURL.match(/\.safelinks\.protection\.outlook\.com\/\?url=.+&data=/)) { - // Handle the case where "&" is encoded as "&" - originalURL = originalURL.split('?url=')[1].split('&data=')[0]; - } - else { - throw new Error('Invalid SafeLinks URL provided'); - } - } - catch (error: any) { - // Handle errors - throw new Error(`Failed to decode SafeLinks URL: ${error}`); - } - - return originalURL; + return new URL(safeLinksUrl).searchParams.get('url') }