-
-
Notifications
You must be signed in to change notification settings - Fork 25
Added parse-email-address package #340
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
Conversation
ref https://linear.app/ghost/issue/FEA-483/sniperlink-support-in-portal-converted-to-project This adds the `@tryghost/parse-email-address` package, which extracts the local and domain parts of email address strings. For example: ``` parseEmailAddress('[email protected]'); // => {local: 'foo', domain: 'example.com'} ``` We'll be able to use this in various places across Ghost. I'll start by parsing the domain for "sniper links" (see Linear).
WalkthroughThis PR introduces a new npm package Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 markdownlint-cli2 (0.18.1)packages/parse-email-address/README.mdmarkdownlint-cli2 v0.18.1 (markdownlint v0.38.0) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ | ||
| "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ | ||
|
|
||
| /* Type Checking */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I enabled much more strictness than Slimer's default. This should not affect anything outside this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made no manual changes to this file other than (1) what Slimer generated (2) installing a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made no changes to either ESLint file.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #340 +/- ##
==========================================
+ Coverage 90.18% 90.21% +0.02%
==========================================
Files 112 113 +1
Lines 7621 7641 +20
Branches 1092 1096 +4
==========================================
+ Hits 6873 6893 +20
Misses 740 740
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/parse-email-address/README.md`:
- Around line 28-29: Update the README text to hyphenate “top-level domain”
wherever it appears; specifically replace the phrase "The top level domain must
have at least two octets." with "The top-level domain must have at least two
octets." (and similarly update any other occurrences of "top level domain") so
the documentation uses correct grammar.
| - Domain names must have at least two labels. `example.com` is okay, `example` is not. | ||
| - The top level domain must have at least two octets. `example.com` is okay, `example.x` is not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyphenate “top-level domain.”
Minor doc grammar: “top level domain” should be “top-level domain”.
✏️ Proposed doc tweak
-- The top level domain must have at least two octets. `example.com` is okay, `example.x` is not.
+- The top-level domain must have at least two octets. `example.com` is okay, `example.x` is not.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Domain names must have at least two labels. `example.com` is okay, `example` is not. | |
| - The top level domain must have at least two octets. `example.com` is okay, `example.x` is not. | |
| - Domain names must have at least two labels. `example.com` is okay, `example` is not. | |
| - The top-level domain must have at least two octets. `example.com` is okay, `example.x` is not. |
🧰 Tools
🪛 LanguageTool
[grammar] ~29-~29: Use a hyphen to join words.
Context: ...omis okay,example` is not. - The top level domain must have at least two octe...
(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents
In `@packages/parse-email-address/README.md` around lines 28 - 29, Update the
README text to hyphenate “top-level domain” wherever it appears; specifically
replace the phrase "The top level domain must have at least two octets." with
"The top-level domain must have at least two octets." (and similarly update any
other occurrences of "top level domain") so the documentation uses correct
grammar.
9larsons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Where'd you find this package? I think that's my only real question/concern, though it's recent and shouldn't really change 🤷.
|
Found it when searching "RFC 5321" on npm. I reviewed the code and it looks almost exactly like what we need. |
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Long emails are now considered invalid. Before: the only limit on email length was that of the request body. After: the whole email is limited to 986 octets and the domain is limited to 253 octets (per SMTP). Domain labels are limited to 63 octets (per DNS). - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Long emails are now considered invalid. Before: the only limit on email length was that of the request body. After: the whole email is limited to 986 octets and the domain is limited to 253 octets (per SMTP). Domain labels are limited to 63 octets (per DNS). - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Long emails are now considered invalid. Before: the only limit on email length was that of the request body. After: the whole email is limited to 986 octets and the domain is limited to 253 octets (per SMTP). Domain labels are limited to 63 octets (per DNS). - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Long emails are now considered invalid. Before: the only limit on email length was that of the request body. After: the whole email is limited to 986 octets and the domain is limited to 253 octets (per SMTP). Domain labels are limited to 63 octets (per DNS). - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Long emails are now considered invalid. Before: the only limit on email length was that of the request body. After: the whole email is limited to 986 octets and the domain is limited to 253 octets (per SMTP). Domain labels are limited to 63 octets (per DNS). - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340
closes https://linear.app/ghost/issue/NY-942/create-and-use-parse-email-address-package-in-core ref #25919 ref TryGhost/framework#342 This creates the `parse-email-address` package (previously reviewed [here][0]--all I did was move it over) and uses it in email normalization, used when sending magic links. This should not change behavior for "normal", lowercase ASCII email addresses. However, it does make several subtler tweaks to the way emails are normalized: - Some totally invalid emails weren't normalized. Before: if `req.body.email` wasn't a string or lacked an `@`, no normalization would occur. The system would then attempt to send an email that'd almost certainly fail. After: these throw a "bad request" error. - Invalid emails with multiple `@` signs were considered valid. Before: `foo@[email protected]` was accepted. After: it is not accepted and throws a "bad request" error. - Domains are now lowercased. Before: `[email protected]` was normalized to `[email protected]`. After: `[email protected]` is normalized to `[email protected]`. [0]: TryGhost/framework#340 Co-authored-by: Steve Larson <[email protected]>
ref https://linear.app/ghost/issue/FEA-483/sniperlink-support-in-portal-converted-to-project
This adds the
@tryghost/parse-email-addresspackage, which extracts the local and domain parts of email address strings. For example:We'll be able to use this in various places across Ghost. I'll start by parsing the domain for "sniper links" (see Linear).
Note
Adds a new reusable package for extracting and normalizing email address parts.
@tryghost/parse-email-addresswithparseEmailAddress(email)returning{local, domain}ornull; wrapsparse-email-addressand normalizes domains vianode:urldomainToASCIIREADME.md,LICENSE,tsconfig.json, ESLint configs) and updatesyarn.lockWritten by Cursor Bugbot for commit 3b90b96. This will update automatically on new commits. Configure here.