alphagov/govuk_content_api — pull request #145 by JordanHatch (2014-01-08 16:26:47+00:00)
Title: Change how the web_url is built for a tag

Only tags in the 'section' tag type actually have public-facing webpages on GOV.UK. Other tag types, such as 'legacy_sources', don't have these, yet the Content API returns a similar looking URL pointing to a browse page which does not exist (eg. ).

This pull request changes how the `web_url` field is built, so that it checks the tag type before returning a URL, and it returns `nil` if it isn't a section tag. If the tag is from the `industry_sector` tag type, this returns a URL for the tag at the root of GOV.UK (eg `/oil-and-gas`).

Returning `nil` feels like the right behaviour because there isn't a public webpage which exists for the entity. This change is unlikely to break clients as there are currently very few tags which are affected by this change.

I acknowledge that the way this is done is hacky. However, there's not a clear place within our publishing platform code where the varying paths for each tag type could be clearly defined. Without a single consistent URL pattern for every tag in the near future, it's something that's difficult to infer without checking for each individual case.