Skip to content

Commit

Permalink
Fix default region for +1 region codes (marmelroy#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Mifsud authored Mar 20, 2020
1 parent 3761437 commit 7251a67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion PhoneNumberKit/PartialFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public final class PartialFormatter {
// MARK: Status

public var currentRegion: String {
return self.currentMetadata?.codeID ?? self.defaultRegion
if self.phoneNumberKit.countryCode(for: self.defaultRegion) != 1 {
return currentMetadata?.codeID ?? "US"
} else {
return self.currentMetadata?.countryCode == 1
? self.defaultRegion
: self.currentMetadata?.codeID ?? self.defaultRegion
}
}

public func nationalNumber(from rawNumber: String) -> String {
Expand Down

0 comments on commit 7251a67

Please sign in to comment.