Website: Preview the PR specified by the referer header#1762
Website: Preview the PR specified by the referer header#1762
Conversation
Enables easy linking to Playground PRs from WordPress and Gutenberg GitHub PRs without interpolating the PR number in the link. This PR adds a https://playground.wordpress.net/preview-referrer-pr.php script that looks at the Referer header, extracts the repo and the PR number from it, and redirects to the relevant PR previewer. ## Testing instructions 1. Run the script on a HTTPS domain (or use my link: https://adamadam.blog/referer.php) 2. Link to that script from a WordPress develop and a Gutenberg PR 3. Click those links 4. Confirm you were redirected to /wordpress.html or /gutenberg.html with a proper `?pr=` query parameter Props to @gziolo for the idea
|
|
||
| if (preg_match('/github\.com\/WordPress\/gutenberg\/pull\/(?<prNumber>\d+)/i', $referrer, $matches)) { | ||
| $prNumber = $matches['prNumber']; | ||
| header('Location: ./gutenberg.html?pr=' . $prNumber); |
There was a problem hiding this comment.
with #1761 would it be helpful to cut out the redirect and launch /?core-pr=${prNumber}?
There was a problem hiding this comment.
That was my first thought, too, but /gutenberg.html will tell you when the artifact isn't ready yet while a direct link would just not load the PR.
|
Nice! I tried to put the link https://adamadam.blog/referer.php in my PR: WordPress/gutenberg#65273. However, it didn't work correctly. |
680cd19 to
2e376d2
Compare
|
Tested and it redirects as mentioned pr-referrer.mp4@adamziel can you confirm screen recording shows expected result? |
|
@ajitbohra it does, thank you for testing! Would you be able to confirm the result is reliable across browsers and different levels of privacy settings? I wonder why it failed for @gziolo |
|
This PR seems stale so I'll close it. Feel free to reopen at any point but also no pressure – it can stay closed and that's fine. |
Enables easy linking to Playground PRs from WordPress and Gutenberg GitHub PRs without interpolating the PR number in the link.
This PR adds a https://playground.wordpress.net/preview-referrer-pr.php script that looks at the Referer header, extracts the repo and the PR number from it, and redirects to the relevant PR previewer.
Testing instructions
?pr=query parameterProps to @gziolo for the idea