Making WordPress.org


Ignore:
Timestamp:
10/13/2022 12:09:10 AM (4 years ago)
Author:
dd32
Message:

Markdown Importer: Support any branch in the imported content, not just master.

Fixes #6538.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-markdown/inc/class-editor.php

    r10140 r12118  
    181181                        return '';
    182182                }
    183                 if ( 'github.com' !== parse_url( $markdown_source, PHP_URL_HOST )
    184                         || false !== stripos( $markdown_source, '/edit/master/' ) ) {
     183
     184                if ( 'github.com' !== parse_url( $markdown_source, PHP_URL_HOST ) ) {
    185185                        return $markdown_source;
    186186                }
    187                 $markdown_source = str_replace( '/blob/master/', '/edit/master/', $markdown_source );
     187
     188                if ( preg_match( '!^https?://github.com/(?P<repo>[^/]+/[^/]+)/(?P<editblob>blob|edit)/(?P<branchfile>.*)$!i', $markdown_source, $m ) ) {
     189                        if ( 'edit' === $m['editblob'] ) {
     190                                return $markdown_source;
     191                        }
     192
     193                        $markdown_source = "https://github.com/{$m['repo']}/edit/{$m['branchfile']}";
     194                }
    188195
    189196                return apply_filters( 'wporg_markdown_edit_link', $markdown_source, $post_id );
Note: See TracChangeset for help on using the changeset viewer.