Skip to content

Commit 5341b68

Browse files
committed
Use regexplanet-common for 'Your Browser' testing
1 parent ab33815 commit 5341b68

File tree

11 files changed

+41
-40
lines changed

11 files changed

+41
-40
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@jsr:registry=https://npm.jsr.io

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"dependencies": {
33
"@popperjs/core": "^2.11.8",
4+
"@regexplanet/common": "npm:@jsr/regexplanet__common@^1.2.0",
45
"bootstrap": "^5.3.3",
56
"fetch-jsonp": "^1.3.0",
67
"next": "^14.2.14",

public/images/browsers/browser-ar21.svg

Lines changed: 10 additions & 6 deletions
Loading

src/app/advanced/[engine]/index.html/OptionsInput.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PiArrowSquareOut } from "react-icons/pi";
44

55
type OptionInputProps = {
66
engine: RegexEngine;
7-
options: string[];
7+
optionsOrNull: string[];
88
};
99

1010
function getBackendValue(option: RegexOption): string {
@@ -15,7 +15,9 @@ function getBackendValue(option: RegexOption): string {
1515
return option.code;
1616
}
1717

18-
export default function OptionsInput({ engine, options }: OptionInputProps) {
18+
export default function OptionsInput({ engine, optionsOrNull }: OptionInputProps) {
19+
20+
const options = optionsOrNull || [];
1921

2022
const optionCheckboxes = engine.options.map((option) => {
2123
const optionValue = getBackendValue(option);

src/app/advanced/[engine]/index.html/TestForm.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
'use client'
22
import React, { useState } from 'react';
3-
import { TestInput } from '@/types/TestInput';
4-
import { TestOutput } from '@/types/TestOutput';
53
import { TestResults } from '@/components/TestResults';
64
import { RegexEngine } from '@/engines/RegexEngine';
75
import OptionsInput from './OptionsInput';
8-
6+
import { runTest as runBrowserTest, type TestInput, type TestOutput } from '@regexplanet/common';
97
type TestFormProps = {
108
engine: RegexEngine;
119
testUrl?: string; // override for use during engine development
@@ -14,10 +12,14 @@ type TestFormProps = {
1412

1513
async function runTest(test_url:string, testInput: TestInput): Promise<TestOutput> {
1614

15+
if (test_url === 'javascript:runBrowserTest') {
16+
return runBrowserTest(testInput);
17+
}
18+
1719
const postData =
1820
`regex=${encodeURIComponent(testInput.regex)}` +
1921
`&replacement=${encodeURIComponent(testInput.replacement)}` +
20-
`&${testInput.option.map((option) => `option=${encodeURIComponent(option)}`).join("&")}` +
22+
`&${testInput.options.map((option) => `option=${encodeURIComponent(option)}`).join("&")}` +
2123
`&${testInput.inputs.map((input) => `input=${encodeURIComponent(input)}`).join("&")}`;
2224

2325
console.log("posting", test_url, postData);
@@ -28,8 +30,9 @@ async function runTest(test_url:string, testInput: TestInput): Promise<TestOutpu
2830
headers: {
2931
"Content-Type": "application/x-www-form-urlencoded",
3032
},
31-
mode: "no-cors",
33+
//mode: "no-cors",
3234
});
35+
console.log("response", response);
3336
const data = await response.json();
3437

3538
console.log("test results", data);
@@ -119,7 +122,7 @@ export default function TestForm(props: TestFormProps) {
119122
<label htmlFor="replacement" className="form-label">Replacement</label>
120123
<input type="text" className="form-control" id="replacement" name="replacement" defaultValue={testInput.replacement} />
121124
</div>
122-
{ props.engine.options.length > 0 ? <OptionsInput engine={props.engine} options={testInput.option} /> : <></> }
125+
{ props.engine.options.length > 0 ? <OptionsInput engine={props.engine} options={testInput.options} /> : <></> }
123126
<button type="submit" className="btn btn-primary">Test</button>
124127
{inputRows}
125128
<button type="submit" className="btn btn-primary">Test</button>
@@ -135,7 +138,7 @@ function formDataToTestInput(engineHandle:string, formData: FormData): TestInput
135138
engine: engineHandle,
136139
regex: formData.get('regex') as string,
137140
replacement: formData.get('replacement') as string,
138-
option: formData.getAll('option') as string[],
141+
options: formData.getAll('option') as string[],
139142
inputs: formData.getAll('input') as string[]
140143
};
141144
return retVal;;

src/engines/browser.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ export const browser: RegexEngine = {
3131
code: "d",
3232
description: "Generate indices for substring matches. (hasIndices)",
3333
},
34-
{ code: "g", legacyCode: "global", description: "Global search. (global)" },
34+
{ code: "g", description: "Global search. (global)" },
3535
{
3636
code: "i",
37-
legacyCode: "ignorecase",
3837
description: "Case-insensitive search. (ignoreCase)",
3938
},
4039
{
4140
code: "m",
42-
legacyCode: "multiline",
4341
description:
4442
"Allows ^ and $ to match next to newline characters. (multiline)",
4543
},
@@ -64,7 +62,7 @@ export const browser: RegexEngine = {
6462
short_name: "Your Browser",
6563
source_url: "https://github.com/regexplanet/regexplanet-next",
6664
status_url: undefined,
67-
test_url: "javascript:",
65+
test_url: "javascript:runBrowserTest",
6866
};
6967

7068

src/engines/nodejs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const nodejs: RegexEngine = {
5656
},*/
5757
],
5858
short_name: "Node.js",
59-
source_url: "https://github.com/regexplanet/regexplanet-js",
60-
status_url: "https://js.gcr.regexplanet.com/status.json",
61-
test_url: "https://js.gcr.regexplanet.com/test.json",
59+
source_url: "https://github.com/regexplanet/regexplanet-nodejs",
60+
status_url: "https://nodejs.gcr.regexplanet.com/status.json",
61+
test_url: "https://nodejs.gcr.regexplanet.com/test.json",
6262
};

src/engines/python.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const python: RegexEngine = {
5858
},
5959
],
6060
short_name: "Python",
61-
source_url: "https://github.com/regexplanet/regexplanet-python",
62-
status_url: "https://regexplanet-python.appspot.com/status.json",
63-
test_url: "https://regexplanet-python.appspot.com/test.json",
61+
source_url: "https://github.com/regexplanet/regexplanet-python3",
62+
status_url: "https://python3.gcr.regexplanet.com/status.json",
63+
test_url: "https://python3.gcr.regexplanet.com/test.json",
6464
};

src/types/TestInput.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)