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

restore unicode_normalize_kc as a deprecated method #504

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/unicode_normalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true.

require "benchmark"
require "addressable/idna/pure.rb"
require_relative "../lib/addressable/idna/pure.rb"
require "idn"

value = "fiᆵリ宠퐱卄.com"
Expand Down
10 changes: 10 additions & 0 deletions lib/addressable/idna/native.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ def self.punycode_decode(value)
IDN::Punycode.decode(value.to_s)
end

class << self
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
def unicode_normalize_kc(value)
value.to_s.unicode_normalize(:nfkc)
end

extend Gem::Deprecate
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
end

def self.to_ascii(value)
value.to_s.split('.', -1).map do |segment|
if segment.size > 0 && segment.size < 64
Expand Down
10 changes: 10 additions & 0 deletions lib/addressable/idna/pure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ def self.to_unicode(input)
output
end

class << self
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
def unicode_normalize_kc(value)
value.to_s.unicode_normalize(:nfkc)
end

extend Gem::Deprecate
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
end

##
# Unicode aware downcase method.
#
Expand Down