Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import * as React from 'react';
import Icon from '../Icon';
import {searchGitHubIssuesURL} from './githubAPI';
import styles from './shared.css';

function encodeURIWrapper(string: string): string {
Expand All @@ -31,6 +32,9 @@ export default function ReportNewIssue({
return null;
}

const gitHubAPISearch =
errorMessage !== null ? searchGitHubIssuesURL(errorMessage) : '(none)';

const title = `Error: "${errorMessage || ''}"`;
const labels = ['Component: Developer Tools', 'Status: Unconfirmed'];

Expand All @@ -57,10 +61,13 @@ If possible, please describe how to reproduce this bug on the website or app men
DevTools version: ${process.env.DEVTOOLS_VERSION || ''}

Call stack:
${callStack || '(not available)'}
${callStack || '(none)'}

Component stack:
${componentStack || '(not available)'}
${componentStack || '(none)'}

GitHub URL search query:
${gitHubAPISearch}
`;

bugURL += `/issues/new?labels=${encodeURIWrapper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export type GitHubIssue = {|

const GITHUB_ISSUES_API = 'https://api.github.com/search/issues';

export async function searchGitHubIssues(
message: string,
): Promise<GitHubIssue | null> {
export function searchGitHubIssuesURL(message: string): string {
// Remove Fiber IDs from error message (as those will be unique).
message = message.replace(/"[0-9]+"/g, '');

Expand All @@ -29,13 +27,19 @@ export async function searchGitHubIssues(
'repo:facebook/react',
];

const response = await fetch(
return (
GITHUB_ISSUES_API +
'?q=' +
encodeURIComponent(message) +
'%20' +
filters.map(encodeURIComponent).join('%20'),
'?q=' +
encodeURIComponent(message) +
'%20' +
filters.map(encodeURIComponent).join('%20')
);
}

export async function searchGitHubIssues(
message: string,
): Promise<GitHubIssue | null> {
const response = await fetch(searchGitHubIssuesURL(message));
const data = await response.json();
if (data.items.length > 0) {
const item = data.items[0];
Expand Down