From 33c00ca11119b35e2bf3bfea6bd77df3d12d9e15 Mon Sep 17 00:00:00 2001 From: Lucas Duailibe Date: Tue, 17 Apr 2018 13:53:20 -0300 Subject: [PATCH] handling PR versions --- website/playground/Playground.js | 23 ++++++++++++++++++++--- website/playground/VersionLink.js | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/website/playground/Playground.js b/website/playground/Playground.js index 7cd848a9..a7e5c5ee 100644 --- a/website/playground/Playground.js +++ b/website/playground/Playground.js @@ -69,7 +69,12 @@ class Playground extends React.Component { this.state.options ); - this.setState({ loaded: true, availableOptions, options, version }); + this.setState({ + loaded: true, + availableOptions, + options, + version: fixPrettierVersion(version) + }); }); } @@ -192,11 +197,15 @@ class Playground extends React.Component { Copy link - this.getMarkdown(formatted, reformatted)}> + this.getMarkdown(formatted, reformatted)} + > Copy markdown @@ -245,6 +254,14 @@ function getSecondFormat(formatted, reformatted) { : reformatted; } +function fixPrettierVersion(version) { + const match = version.match(/^\d+\.\d+\.\d+-pr.(\d+)$/); + if (match) { + return `pr-${match[1]}`; + } + return version; +} + function getDefaultOptions(availableOptions) { return availableOptions.reduce((acc, option) => { acc[option.name] = option.default; diff --git a/website/playground/VersionLink.js b/website/playground/VersionLink.js index 23b5384a..713aaa71 100644 --- a/website/playground/VersionLink.js +++ b/website/playground/VersionLink.js @@ -4,7 +4,7 @@ import ReactDOM from "react-dom"; const root = document.getElementById("version"); export default function({ version }) { - const match = version.match(/^\d+\.\d+\.\d+-.(\d+)$/); + const match = version.match(/^pr-(\d+)$/); let href; if (match) { href = `pull/${match[1]}`;