#6538 closed defect (bug) (fixed)
wporg-markdown importer - Support GitHub branches not named `master`
Reported by: | netweb | Owned by: | dd32 |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | Handbooks | Keywords: | |
Cc: |
Description
Currently the get_markdown_edit_link()
function hard codes the GitHub edit
link to master
: (Source)
if ( 'github.com' !== parse_url( $markdown_source, PHP_URL_HOST ) || false !== stripos( $markdown_source, '/edit/master/' ) ) { return $markdown_source; } $markdown_source = str_replace( '/blob/master/', '/edit/master/', $markdown_source );
Discovered after merging https://github.com/WordPress/WordPress-Documentation-Style-Guide/pull/20 where the default branch is main
, prior to merging the above PR the GitHub "edit" URL on pages were in the form:
https://github.com/WordPress/WordPress-Documentation-Style-Guide/edit/master/docs/2-general-guidelines/6-facts-claims.md
The above URL format 404s as the master
branch no longer exists on GitHub
The new "edit" URL on pages is:
https://github.com/WordPress/WordPress-Documentation-Style-Guide/main/docs/2-general-guidelines/6-facts-claims.md
And as such the URL doesn't include /edit/main
, just /main
, so the URL opens correctly just not in the previous "edit" mode.
My suggestion would be to update the above function to account for common dotorg repo branch names used: trunk
, main
, and master
Change History (3)
Note: See
TracTickets for help on using
tickets.
In 12118: