Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ershad Kunnakkadan <[email protected]>
  • Loading branch information
vishaltelangre and ershad authored May 3, 2021
1 parent 2d77f08 commit 31c404b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gumroad/includes/scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function gum_post_scanner( $post_object ) {
function scanner( $post_content ) {

// counts to see if we find any gumroad product links.
if (count(preg_grep('/(gumroad.com\/a\/.+\/[[:alnum:]].*|gumroad.com\/l\/[[:alnum:]]|gum.co\/[[:alnum:]])/', explode("\n", $post_content))) > 0) {
if (count(preg_grep('/(gumroad.com\/a\/[[:alnum:]]+\/[[:alnum:]].*|gumroad.com\/l\/[[:alnum:]]|gum.co\/[[:alnum:]])/', explode("\n", $post_content))) > 0) {
gum_load_js('overlay');
}
if (count(preg_grep('/(class=\"gumroad-product-embed\")/', explode("\n", $post_content))) > 0) {
Expand Down
1 change: 0 additions & 1 deletion gumroad/includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function gum_gumroad_shortcode( $attr ) {
if ( ! empty( $url ) ) {
// Embed widget doesn't work with alias domain URLs
$attr['url'] = str_replace('gum.co/a/', 'gumroad.com/a/', $attr['url']);
$attr['url'] = str_replace('gum.co/l/', 'gumroad.com/l/', $attr['url']);
$attr['url'] = str_replace('gum.co/', 'gumroad.com/l/', $attr['url']);
}

Expand Down
3 changes: 1 addition & 2 deletions gumroad/src/gumroad-block/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {

const gumroadURL = 'https://gumroad.com/l/demo';
const defaultID = 'demo';
const gumroadURLRegex = /(https:\/\/gumroad\.com\/a\/.+\/)|(https:\/\/gumroad\.com\/l\/)|(https:\/\/gumroad\.com\/)|(https:\/\/gum\.co\/l\/)|(https:\/\/gum\.co\/)/g;
const gumroadURLRegex = /(https:\/\/gumroad\.com\/a\/[[:alnum:]]+\/)|(https:\/\/gumroad\.com\/l\/)|(https:\/\/gumroad\.com\/)|(https:\/\/gum\.co\/)/g;

class GumControls extends Component {
constructor( props ) {
Expand Down Expand Up @@ -226,7 +226,6 @@ registerBlockType( 'gumroad/gumroad-block', {
// Embed widget doesn't work with alias domain URLs
urlString = urlString
.replace("gum.co/a/", "gumroad.com/a/")
.replace("gum.co/l/", "gumroad.com/l/")
.replace("gum.co/", "gumroad.com/l/");

// Wanted
Expand Down

0 comments on commit 31c404b

Please sign in to comment.