Better implementation of CMS_API.source_of_path_alias (a_alias).
That now returns the path, only if the alias exists, otherwise returns Void. Improved path alias validation.
This commit is contained in:
@@ -122,8 +122,10 @@ feature -- Forms ...
|
|||||||
else
|
else
|
||||||
-- TODO: implement full path alias validation
|
-- TODO: implement full path alias validation
|
||||||
end
|
end
|
||||||
if attached a_response.api.location_alias (f_path_alias) as l_aliased_location then
|
if
|
||||||
fd.report_invalid_field ("path_alias", "Path is already aliazed to location %"" + l_aliased_location + "%" !")
|
attached a_response.api.source_of_path_alias (f_path_alias) as l_aliased_location
|
||||||
|
then
|
||||||
|
fd.report_invalid_field ("path_alias", "Path is already aliased to location %"" + a_response.link (Void, l_aliased_location, Void) + "%" !")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end(?, response)
|
end(?, response)
|
||||||
|
|||||||
@@ -326,18 +326,17 @@ feature -- Path aliases
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
source_of_path_alias (a_alias: READABLE_STRING_8): READABLE_STRING_8
|
source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
|
||||||
-- Resolved path for alias `a_alias'.
|
-- Resolved path for alias `a_alias'.
|
||||||
--| the CMS supports aliases for path, and then this function simply returns
|
--| the CMS supports aliases for path, and then this function simply returns
|
||||||
--| the effective target path/url for this `a_alias'.
|
--| the effective target path/url for this `a_alias'.
|
||||||
--| For instance: articles/2015/may/this-is-an-article can be an alias to node/123
|
--| For instance: articles/2015/may/this-is-an-article can be an alias to node/123
|
||||||
--| This function will return "node/123".
|
--| This function will return "node/123".
|
||||||
--| If the alias is bad (i.e does not alias real path), then this function
|
--| If the alias is bad (i.e does not alias real path), then this function
|
||||||
--| returns the alias itself.
|
--| returns Void.
|
||||||
do
|
do
|
||||||
Result := a_alias
|
if attached storage.source_of_path_alias (a_alias) as l_source_path then
|
||||||
if attached storage.source_of_path_alias (Result) as l_path then
|
Result := l_source_path
|
||||||
Result := l_path
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ feature {WSF_ROUTER_MAPPING} -- Dispatch helper
|
|||||||
if not l_path.is_empty and l_path [1] = '/' then
|
if not l_path.is_empty and l_path [1] = '/' then
|
||||||
l_path.remove_head (1)
|
l_path.remove_head (1)
|
||||||
end
|
end
|
||||||
Result := api.source_of_path_alias (l_path)
|
if attached api.source_of_path_alias (l_path) as l_aliased_path then
|
||||||
|
Result := l_aliased_path
|
||||||
|
else
|
||||||
|
Result := l_path
|
||||||
|
end
|
||||||
if Result.is_empty then
|
if Result.is_empty then
|
||||||
Result := "/"
|
Result := "/"
|
||||||
elseif Result [1] /= '/' then
|
elseif Result [1] /= '/' then
|
||||||
@@ -49,4 +53,7 @@ feature {WSF_ROUTER_MAPPING} -- Dispatch helper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user