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

Reader: Ensure URL Scheme in Subscription List Component #95676

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

eoigal
Copy link
Contributor

@eoigal eoigal commented Oct 24, 2024

Related to #95624

The curated list URLs do not have 'http://' prefixes which means that the Subscribe API requests fail with the following error;

{
    "code": 200,
    "headers": [
        {
            "name": "Content-Type",
            "value": "application\/json"
        }
    ],
    "body": {
        "info": "invalid_url",
        "subscribed": false
    }
}

This code change adds logic to ensure that the url property in the component always includes a proper URL scheme (i.e., http:// or https://).

If ownProps.url already starts with http:// or https://, it will be left unchanged. However, if the URL doesn't start with a valid scheme, http:// is prepended to it. This change is applied in the connect function, which manages the component's data connection to the state and props.

This ensures that the url is always a valid, complete URL when passed to the component.

Proposed Changes

  • Adds http:// to site URL if missing - this is needed when subscribing to a site

Why are these changes being made?

Testing Instructions

  • Using Calypso Live, go to /read?flags=reader/onboarding
  • You can clear the preference flag to make the banner reappear by using the DEV tools found in the bottom right of the screen.
Screenshot 2024-10-21 at 5 10 55 PM * Click on the `Discover and subscribe to sites you'll love` to open blog suggestions * Confirm you can subscribe to a blog * Confirm you can subscribe to a blog on the `/discover` popular blogs (in sidebar)

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@eoigal eoigal requested a review from a team as a code owner October 24, 2024 14:47
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 24, 2024
@eoigal eoigal changed the title Reader: add missng http when subscribing Reader: Ensure URL Scheme in Subscription List Component Oct 24, 2024
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~36 bytes added 📈 [gzipped])

name    parsed_size           gzip_size
reader        +56 B  (+0.0%)      +36 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~35 bytes added 📈 [gzipped])

name                      parsed_size           gzip_size
async-load-design-blocks        +56 B  (+0.0%)      +35 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/onboarding-subscribe on your sandbox.

@@ -96,6 +96,7 @@ class ConnectedSubscriptionListItem extends Component {
export default compose(
connect( ( state, ownProps ) => ( {
isFollowing: isFollowingSelector( state, { feedId: ownProps.feedId, blogId: ownProps.siteId } ),
url: ownProps.url.match( /^https?:\/\// ) ? ownProps.url : `http://${ ownProps.url }`,
Copy link
Member

@allilevine allilevine Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we prepend https vs. http?

Copy link
Member

@allilevine allilevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, though I noticed that the curated list URLs are inconsistent -- some have it, some don't. With this PR we don't need to worry about it, but we could alternatively add the correct URL scheme to all of the URLs instead.

I also noticed some URLs that aren't URLs and opened a separate PR: #95686

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants