# HG changeset patch # User Ruslan Ermilov # Date 1341002006 0 # Node ID fd3eefefa5f929799a13177a0fa2ba083b8a2b68 # Parent 7f8d224d3bfb2ed83b4bb602b4dffa2c23ccf83d map: strip final dot before looking up in a map of hostnames. (closes #182) diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c --- a/src/http/modules/ngx_http_map_module.c +++ b/src/http/modules/ngx_http_map_module.c @@ -110,7 +110,6 @@ ngx_http_map_variable(ngx_http_request_t { ngx_http_map_ctx_t *map = (ngx_http_map_ctx_t *) data; - size_t len; ngx_str_t val; ngx_http_variable_value_t *value; @@ -121,10 +120,8 @@ ngx_http_map_variable(ngx_http_request_t return NGX_ERROR; } - len = val.len; - - if (len && map->hostnames && val.data[len - 1] == '.') { - len--; + if (map->hostnames && val.len > 0 && val.data[val.len - 1] == '.') { + val.len--; } value = ngx_http_map_find(r, &map->map, &val); @@ -281,6 +278,8 @@ ngx_http_map_block(ngx_conf_t *cf, ngx_c map->default_value = ctx.default_value ? ctx.default_value: &ngx_http_variable_null_value; + map->hostnames = ctx.hostnames; + hash.key = ngx_hash_key_lc; hash.max_size = mcf->hash_max_size; hash.bucket_size = mcf->hash_bucket_size;