diff --git a/ngx_rtmp_relay_module.c b/ngx_rtmp_relay_module.c index 20cfcd9..bf6dd48 100644 --- a/ngx_rtmp_relay_module.c +++ b/ngx_rtmp_relay_module.c @@ -741,8 +741,8 @@ ngx_rtmp_relay_send_connect(ngx_rtmp_session_t *s) ngx_rtmp_core_srv_conf_t *cscf; ngx_rtmp_relay_ctx_t *ctx; ngx_rtmp_header_t h; - size_t len; - u_char *p; + size_t len, url_len; + u_char *p, *url_end; cacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_core_module); @@ -774,7 +774,14 @@ ngx_rtmp_relay_send_connect(ngx_rtmp_session_t *s) } out_cmd[1].data = p; p = ngx_cpymem(p, "rtmp://", sizeof("rtmp://") - 1); - p = ngx_cpymem(p, ctx->url.data, ctx->url.len); + + url_len = ctx->url.len; + url_end = ngx_strlchr(ctx->url.data, ctx->url.data + ctx->url.len, '/'); + if (url_end) { + url_len = (size_t) (url_end - ctx->url.data); + } + + p = ngx_cpymem(p, ctx->url.data, url_len); *p++ = '/'; p = ngx_cpymem(p, ctx->app.data, ctx->app.len); out_cmd[1].len = p - (u_char *)out_cmd[1].data;