Skip to content

Remove possible double slashes in hand-crafted URLs

Máté Cserép requested to merge 89-url-trailing-slash into develop

In some cases URLs are not generated through Yii, but are "hand-crafted" through string concatenation.

  • These are definitely required when creating frontend URLs.
  • It also used in some cases when creating backend URLs (which should be refactored later).

While Yii removes trailing slashes and collapses double slashes by default (see the UrlNormalizer class), it is of course not done when the URLs are not created through Yii.

When Yii::$app->params['frontendUrl'] (or Yii::$app->params['backendUrl']) ends with a trailing slash, a double slash can be formed in the URL. This MR provides a quick and easy fix for that issue. Maybe later a more robust solution should be implemented, by creating a custom URL generator for cases when Yii's URL creator cannot be used.

Closes #89 (closed)

Edited by Máté Cserép

Merge request reports