Skip to content
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

Website: Preview the PR specified by the referer header #1762

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/playground/website/public/preview-referrer-pr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

$referrer = $_SERVER['HTTP_REFERER'];
$prNumber = null;

if (preg_match('/github\.com\/WordPress\/gutenberg\/pull\/(?<prNumber>\d+)/i', $referrer, $matches)) {
$prNumber = $matches['prNumber'];
header('Location: ./gutenberg.html?pr=' . $prNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with #1761 would it be helpful to cut out the redirect and launch /?core-pr=${prNumber}?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a possible enhancement for #1761 down the line 😉

exit;
} else if (preg_match('/github\.com\/WordPress\/wordpress-develop\/pull\/(?<prNumber>\d+)/i', $referrer, $matches)) {
$prNumber = $matches['prNumber'];
header('Location: ./wordpress.html?pr=' . $prNumber);
exit;
} else {
header('HTTP/1.1 403 Forbidden');
echo 'Invalid referrer';
exit;
}
Loading