Bug: Internal Server Error when a query string is at the end of a post with date permalinks

I think I’ve found a bug - when you use either the day and name or month and name permalinks option on wordpress, query parameters cause an internal server error, specifically:

TypeError: Cannot read property ‘slice’ of null
at extractParameters (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/get-match.ts:16:34)
at getMatch (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/get-match.ts:26:507)
at eval (webpack-internal:///./node_modules/@frontity/wp-source/src/actions.ts:22:84)
at Object.eval [as fetch] (webpack-internal:///./node_modules/@frontity/connect/src/create-store.js:8:725)
at eval (webpack-internal:///./node_modules/@frontity/tiny-router/src/actions.ts:70:143)
at eval (webpack-internal:///./node_modules/@frontity/connect/src/create-store.js:8:725)
at eval (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:63:88)
at Array.map ()
at eval (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:63:48)
at runMicrotasks ()

I noticed this issue after I changed permalinks from /Category/year/month/day/slug to just year/month/day/slug on my main project (cnbcafrica.com) and have been able to replicate it here https://frontity-93ryx00hc.vercel.app/2020/11/10/nigeria-exempts-dangote-cement-from-land-border-closure/?Asds=1

My repo is here: https://github.com/africabusinessnews/frontity

I’ve tried it with 5-6 different wordpress sites - it always fails when there is a day or month permalink.

The query strings that failed (All fail, but the ones I speciffically need working) are ?fbclid= from Facebook or mc_cid from mailchimp.

Update: When I change permalinks to include a category or just use the post name, it works fine.

Is there a way to remove query strings from the link before frontity handles the url?

System info:

System:

  • OS: Windows 10 10.0.19042
  • CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
  • Memory: 18.65 GB / 31.93 GB

Binaries:

  • Node: 12.18.4 - C:\Program Files\nodejs\node.EXE
  • npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD

Browsers:

  • Chrome: 87.0.4280.141
  • Edge: Spartan (44.19041.423.0)
  • Internet Explorer: 11.0.19041.1

npmPackages:

  • @auth0/auth0-react: ^1.2.0 => 1.2.0
  • @brightcove/react-player-loader: ^1.4.1 => 1.4.1
  • @frontity/core: ^1.9.1 => 1.9.1
  • @frontity/google-ad-manager: ^0.1.2 => 0.1.2
  • @frontity/google-tag-manager-analytics: ^1.1.1 => 1.1.1
  • @frontity/head-tags: ^1.0.8 => 1.0.8
  • @frontity/html2react: ^1.5.0 => 1.5.0
  • @frontity/mars-theme: ./packages/mars-theme => 1.4.3
  • @frontity/tiny-router: ^1.2.4 => 1.2.4
  • @frontity/wp-source: ^1.10.0 => 1.10.0
  • bootstrap: ^4.6.0 => 4.6.0
  • frontity: ^1.13.0 => 1.13.0
  • react-bootstrap: ^1.4.3 => 1.4.3
  • react-bootstrap/AbstractNav: undefined ()
  • react-bootstrap/AbstractNavItem: undefined ()
  • react-bootstrap/Accordion: undefined ()
  • react-bootstrap/AccordionCollapse: undefined ()
  • react-bootstrap/AccordionContext: undefined ()
  • react-bootstrap/AccordionToggle: undefined ()
  • react-bootstrap/Alert: undefined ()
  • react-bootstrap/Badge: undefined ()
  • react-bootstrap/BootstrapModalManager: undefined ()
  • react-bootstrap/Breadcrumb: undefined ()
  • react-bootstrap/BreadcrumbItem: undefined ()
  • react-bootstrap/Button: undefined ()
  • react-bootstrap/ButtonGroup: undefined ()
  • react-bootstrap/ButtonToolbar: undefined ()
  • react-bootstrap/Card: undefined ()
  • react-bootstrap/CardColumns: undefined ()
  • react-bootstrap/CardContext: undefined ()
  • react-bootstrap/CardDeck: undefined ()
  • react-bootstrap/CardGroup: undefined ()
  • react-bootstrap/CardImg: undefined ()
  • react-bootstrap/Carousel: undefined ()
  • react-bootstrap/CarouselCaption: undefined ()
  • react-bootstrap/CarouselItem: undefined ()
  • react-bootstrap/CloseButton: undefined ()
  • react-bootstrap/Col: undefined ()
  • react-bootstrap/Collapse: undefined ()
  • react-bootstrap/Container: undefined ()
  • react-bootstrap/Dropdown: undefined ()
  • react-bootstrap/DropdownButton: undefined ()
  • react-bootstrap/DropdownItem: undefined ()
  • react-bootstrap/DropdownMenu: undefined ()
  • react-bootstrap/DropdownToggle: undefined ()
  • react-bootstrap/ElementChildren: undefined ()
  • react-bootstrap/Fade: undefined ()
  • react-bootstrap/Feedback: undefined ()
  • react-bootstrap/Figure: undefined ()
  • react-bootstrap/FigureCaption: undefined ()
  • react-bootstrap/FigureImage: undefined ()
  • react-bootstrap/Form: undefined ()
  • react-bootstrap/FormCheck: undefined ()
  • react-bootstrap/FormCheckInput: undefined ()
  • react-bootstrap/FormCheckLabel: undefined ()
  • react-bootstrap/FormContext: undefined ()
  • react-bootstrap/FormControl: undefined ()
  • react-bootstrap/FormFile: undefined ()
  • react-bootstrap/FormFileInput: undefined ()
  • react-bootstrap/FormFileLabel: undefined ()
  • react-bootstrap/FormGroup: undefined ()
  • react-bootstrap/FormLabel: undefined ()
  • react-bootstrap/FormText: undefined ()
  • react-bootstrap/Image: undefined ()
  • react-bootstrap/InputGroup: undefined ()
  • react-bootstrap/Jumbotron: undefined ()
  • react-bootstrap/ListGroup: undefined ()
  • react-bootstrap/ListGroupItem: undefined ()
  • react-bootstrap/Media: undefined ()
  • react-bootstrap/Modal: undefined ()
  • react-bootstrap/ModalBody: undefined ()
  • react-bootstrap/ModalContext: undefined ()
  • react-bootstrap/ModalDialog: undefined ()
  • react-bootstrap/ModalFooter: undefined ()
  • react-bootstrap/ModalHeader: undefined ()
  • react-bootstrap/ModalTitle: undefined ()
  • react-bootstrap/Nav: undefined ()
  • react-bootstrap/NavContext: undefined ()
  • react-bootstrap/NavDropdown: undefined ()
  • react-bootstrap/NavItem: undefined ()
  • react-bootstrap/NavLink: undefined ()
  • react-bootstrap/Navbar: undefined ()
  • react-bootstrap/NavbarBrand: undefined ()
  • react-bootstrap/NavbarCollapse: undefined ()
  • react-bootstrap/NavbarContext: undefined ()
  • react-bootstrap/NavbarToggle: undefined ()
  • react-bootstrap/Overlay: undefined ()
  • react-bootstrap/OverlayTrigger: undefined ()
  • react-bootstrap/PageItem: undefined ()
  • react-bootstrap/Pagination: undefined ()
  • react-bootstrap/Popover: undefined ()
  • react-bootstrap/PopoverContent: undefined ()
  • react-bootstrap/PopoverTitle: undefined ()
  • react-bootstrap/ProgressBar: undefined ()
  • react-bootstrap/ResponsiveEmbed: undefined ()
  • react-bootstrap/Row: undefined ()
  • react-bootstrap/SafeAnchor: undefined ()
  • react-bootstrap/SelectableContext: undefined ()
  • react-bootstrap/Spinner: undefined ()
  • react-bootstrap/SplitButton: undefined ()
  • react-bootstrap/Switch: undefined ()
  • react-bootstrap/Tab: undefined ()
  • react-bootstrap/TabContainer: undefined ()
  • react-bootstrap/TabContent: undefined ()
  • react-bootstrap/TabContext: undefined ()
  • react-bootstrap/TabPane: undefined ()
  • react-bootstrap/Table: undefined ()
  • react-bootstrap/Tabs: undefined ()
  • react-bootstrap/ThemeProvider: undefined ()
  • react-bootstrap/Toast: undefined ()
  • react-bootstrap/ToastBody: undefined ()
  • react-bootstrap/ToastContext: undefined ()
  • react-bootstrap/ToastHeader: undefined ()
  • react-bootstrap/ToggleButton: undefined ()
  • react-bootstrap/ToggleButtonGroup: undefined ()
  • react-bootstrap/Tooltip: undefined ()
  • react-bootstrap/createChainedFunction: undefined ()
  • react-bootstrap/createWithBsPrefix: undefined ()
  • react-bootstrap/divWithClassName: undefined ()
  • react-bootstrap/helpers: undefined ()
  • react-bootstrap/triggerBrowserReflow: undefined ()
  • react-bootstrap/types: undefined ()
  • react-bootstrap/usePopperMarginModifiers: undefined ()
  • react-bootstrap/useWrappedRefWithWarning: undefined ()
  • react-youtube: ^7.13.0 => 7.13.0

npmGlobalPackages:

  • frontity: Not Found
  • npx: Not Found

System info copied in the clipboard!
You can now paste it in the Frontity Community or GitHub issue.

I’m not able to reproduce this on a Mac, tried node versions 10, 12, and 14. Can anybody running Windows confirm this error?

I can try.

What are the exact steps to reproduce the problem?

  1. Set permalinks on wordpress to /%year%/%monthnum%/%day%/%postname%/
  2. add a query string to the end of the url for a post like, “?something=somthingelse12213”

This is on the mars theme. Not sure if that makes a difference.

Ok, thanks @swahi!

No need to check in Windows, this is a known bug and @cristianbote is working right now in a fix: https://github.com/frontity/frontity/issues/596

Please subscribe to the issue to know when it is merged and released, probably in the next weeks :slightly_smiling_face:

Thanks @luisherranz!