3 posts about #programming

Underscores are not allowed as part of domain names

According to rfc1035, underscores (_) are not allowed as part of domain names.

The labels must follow the rules for ARPANET host names. They must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen (-). There are also some restrictions on the length. Labels must be 63 characters or less.

This means domain names like my_domain.com or sub_domain.main-domain.com are invalid.

Special thanks to @jclopezdev for finding this out.

Learned by kevin-perez on Sep 28, 2021

973983 adforcodereview v3 0211021 c02 021121

StimulusReflex + ActiveStorage + Localhost

As it turns out, when you're working with StimulusReflex and ActiveStorage to store Images for a given model, you need to setup default_url_options in development.rb to

 config.action_controller.default_url_options ={ host: 'localhost', port: 3000 }

otherwise, they will be rendered with www.example.org/ host and won't show properly

Learned by carlos-muniz on Mar 8, 2021

973983 adforcodereview v3 0211021 c02 021121

Strip and downcase email addresses if you're using them as lookup keys for anything

Seems like something I need to learn every few years, and recently popped up on one of my side projects. If you're relying on email addresses as lookup keys, for instance in authentication/login scenarios, then standardize on lowercase and strip whitespace for good measure.

This came up when a customer was not able to get inbound email processing to work for his account. Turns out that his user record had a properly downcased email, but his SMTP server was sending his email address with capitalization. Some string massaging fixed the immediate issue.

User.find_by(email: reply_params["sender"].to_s.downcase)

After putting this fix in, I found everywhere else in the system that email addresses come in as input and gave them the same treatment.

Learned by obie-fernandez on Feb 17, 2021

973983 adforcodereview v3 0211021 c02 021121