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

Escape token extraction #64

Merged
merged 1 commit into from
Mar 20, 2016
Merged

Escape token extraction #64

merged 1 commit into from
Mar 20, 2016

Conversation

erikreedstrom
Copy link
Contributor

This change allows monkey-patched charsets that contain regex protected characters to be used.

For example, the following initializer declares a charset that adds -. As a result, any short token including the - will currently fail token extraction.

config/initializers/shortener.rb

module Shortener
  send(:remove_const, :CHARSETS) if const_defined?(:CHARSETS)

  CHARSETS = {
    # Exclude vowels to preclude errant creation of words
    alphanumsafe: (('b'..'z').to_a + ('b'..'Z').to_a).reject { |l| l =~ /[eiou]/i } + (0..9).to_a + %w(- _),
  }
end

Shortener.default_redirect = Rails.application.secrets.web_host_share
Shortener.unique_key_length = 6
Shortener.charset = :alphanumsafe

@erikreedstrom
Copy link
Contributor Author

Test failure is issue with Rake 11.0 breaking change.
Ref: /lib/rake/task_manager.rb#L8

Need to pin Rake to < 11 or implement monkey patch.

jpmcgrath added a commit that referenced this pull request Mar 20, 2016
@jpmcgrath jpmcgrath merged commit 1df605b into jpmcgrath:develop Mar 20, 2016
@jpmcgrath
Copy link
Owner

@erikreedstrom Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants