Skip to content

Commit

Permalink
Fix bug where ? was left when no params were leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
rknightuk committed Sep 4, 2021
1 parent 3f11f36 commit e9e9a7d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions TrackerZapper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.rknightuk.TrackerZapper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -323,7 +323,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.rknightuk.TrackerZapper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.
7 changes: 6 additions & 1 deletion TrackerZapper/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
params = params.filter { !$0.starts(with: r)}
}
let joinedParams = params.joined(separator: "&")
let formattedUrl = "\(urlParts[0])?\(joinedParams)"
print(joinedParams)
var formattedUrl = "\(urlParts[0])?\(joinedParams)"

This comment has been minimized.

Copy link
@devnoname120

devnoname120 Feb 3, 2022

The parsing of URLs is fragile, and I think it's the reason why this issue happens: #18

What would you think about using URLComponents instead?
You can modify the relevant parts of the object and then eventually call .string to get the newly modified URL.

if (joinedParams == "")
{
formattedUrl = urlParts[0]
}
formatted = formatted.replacingOccurrences(of: url, with: formattedUrl)
}
}
Expand Down

0 comments on commit e9e9a7d

Please sign in to comment.