-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix(ia): deprecate webhooks global endpoint #3529
base: epic/ia
Are you sure you want to change the base?
Conversation
'Endpoint disabled due to error:', | ||
'Endpoint disabled due to error', | ||
'newspack-plugin' | ||
) }: ${ endpoint.disabled_error }`; |
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.
This was printing two :
, removed the one from the localized string
url: string | undefined, | ||
url: string, |
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.
Not sure why this would ever be undefined
so I removed it
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.
@miguelpeixe code looks good, I made one non-blocking comment about validating URLs below. Feel free to keep or change as you think!
* @param url The URL to validate. | ||
* @return Error message if URL is invalid, false otherwise. | ||
*/ | ||
export function validateUrl( url: string ): string | false { |
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.
This can be modernized to use URL interface for example:
export function validateUrl( url: string ): string | false {
if ( ! url ) {
return __( 'URL is required.', 'newspack-plugin' );
}
try {
const urlObject = new URL( url );
// Ensure the protocol is either http or https
if ( ! [ 'http:', 'https:' ].includes( urlObject.protocol ) ) {
return __( 'URL must use HTTP or HTTPS protocol.', 'newspack-plugin' );
}
return false;
} catch ( error ) {
return __( 'Invalid URL format.', 'newspack-plugin' );
}
}
There is also a function inside @wordpress/url
called isUrl
which also validates urls using the above pattern.
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.
Good call! Updated in 9eb2589. While at it, I also restricted to HTTPS, which is enforced in the backend.
All Submissions:
Changes proposed in this Pull Request:
1205919985867982-as-1208628153846581/f
Implements changes from #3492 to the IA project.
How to test the changes in this Pull Request:
Other information: