diff --git a/changelog/fix-documents-api-regex b/changelog/fix-documents-api-regex new file mode 100644 index 00000000000..79d7ad4daf8 --- /dev/null +++ b/changelog/fix-documents-api-regex @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix Documents API regex to allow documents with dashes in name to be viewed. diff --git a/includes/wc-payment-api/class-wc-payments-api-client.php b/includes/wc-payment-api/class-wc-payments-api-client.php index d1a07e720ab..b0247f6f8af 100644 --- a/includes/wc-payment-api/class-wc-payments-api-client.php +++ b/includes/wc-payment-api/class-wc-payments-api-client.php @@ -1795,7 +1795,7 @@ public function get_documents_summary( array $filters = [] ) { * @throws API_Exception - If not connected or request failed. */ public function get_document( $document_id ) { - if ( ! preg_match( '/^\w+$/', $document_id ) ) { + if ( ! preg_match( '/^[\w-]+$/', $document_id ) ) { throw new API_Exception( __( 'Route param validation failed.', 'woocommerce-payments' ), 'wcpay_route_validation_failure',