Skip to content

Commit 2763340

Browse files
authored
Merge pull request #176 from Josh-Cena/fix-playground
fix: allow playground regex to contain query with no value
2 parents f937afa + 2869618 commit 2763340

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/modules/playground.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function getSelectionQueryParams(query: string, numLines: number) {
201201
const [startLine, endLine] = ['pln', 'ssl']
202202
// @ts-expect-error parseInt(null) is okay here since we check for NaN
203203
.map(name => parseInt(params.get(name)))
204-
.map(n => (n !== NaN && 1 <= n && n <= numLines ? n : undefined))
204+
.map(n => (!Number.isNaN(n) && 1 <= n && n <= numLines ? n : undefined))
205205
.sort((a, b) => (a ?? Infinity) - (b ?? Infinity));
206206

207207
return { startLine, endLine };

src/util/codeBlocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getReferencedMessage } from './getReferencedMessage';
44

55
const CODEBLOCK_REGEX = /```(?:ts|typescript)?\n([\s\S]+)```/;
66

7-
export const PLAYGROUND_REGEX = /https?:\/\/(?:www\.)?(?:typescriptlang|staging-typescript)\.org\/(?:play|dev\/bug-workbench)(?:\/index\.html)?\/?(\??(?:\w+=[^\s#&]+)?(?:\&\w+=[^\s#&]+)*)#code\/([\w\-%+_]+={0,4})/;
7+
export const PLAYGROUND_REGEX = /https?:\/\/(?:www\.)?(?:typescriptlang|staging-typescript)\.org\/(?:play|dev\/bug-workbench)(?:\/index\.html)?\/?(\??(?:\w+=[^\s#&]*)?(?:\&\w+=[^\s#&]*)*)#code\/([\w\-%+_]+={0,4})/;
88

99
export async function findCode(message: Message, ignoreLinks = false) {
1010
const codeInMessage = findCodeInMessage(message, ignoreLinks);

0 commit comments

Comments
 (0)