Skip to content

Commit

Permalink
Remove ^ and |
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerkretzmar committed Aug 3, 2024
1 parent fd7f27f commit 581f58c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class Route {
// Transform the route's template into a regex that will match a hydrated URL,
// by replacing its parameter segments with matchers for parameter values
const pattern = this.template
.replace(/[.*+^$()|[\]]/g, '\\$&')
.replace(/[.*+$()[\]]/g, '\\$&')
.replace(/(\/?){([^}?]*)(\??)}/g, (_, slash, segment, optional) => {
const regex = `(?<${segment}>${
this.wheres[segment]?.replace(/(^\^)|(\$$)/g, '') || '[^/?]+'
Expand Down
4 changes: 2 additions & 2 deletions tests/js/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const defaultZiggy = {
parameters: ['storefront', 'catalog_uri'],
},
regexSpecialChars: {
uri: 'test.*+^$()|[]/{slug}',
uri: 'test.*+$()[]/{slug}',
methods: ['GET', 'HEAD'],
},
},
Expand Down Expand Up @@ -1444,7 +1444,7 @@ describe('current()', () => {
});

test('matches route with escaped Regex special characters', () => {
global.window.location.pathname = '/test.*+^$()|[]/1';
global.window.location.pathname = '/test.*+$()[]/1';

expect(route().current()).toBe('regexSpecialChars');
expect(route().current('regexSpecialChars')).toBe(true);
Expand Down

0 comments on commit 581f58c

Please sign in to comment.