Ref #25.
Unified · Split
| @@ -32,6 +32,7 @@ class App < Sinatra::Application · 31 unmodified lines | ||
| 32 | 32 | Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| |
| 33 | 33 | doc['full_name'] = doc['name'].dup |
| 34 | 34 | doc['full_name'] << " #{doc['version']}" if doc['version'] |
| 35 | + doc['slug_without_version'] = doc['slug'].split('~').first | |
| 35 | 36 | [doc['slug'], doc] |
| 36 | 37 | }] |
| 37 | 38 | } |
| @@ -123,9 +124,8 @@ class App < Sinatra::Application · 85 unmodified lines | ||
| 123 | 124 | |
| 124 | 125 | def find_doc(slug) |
| 125 | 126 | settings.docs[slug] || begin |
| 126 | − slug = "#{slug}~" | |
| 127 | − settings.docs.each do |_slug, _doc| | |
| 128 | − return _doc if _slug.start_with?(slug) | |
| 127 | + settings.docs.each do |_, doc| | |
| 128 | + return doc if doc['slug_without_version'] == slug | |
| 129 | 129 | end |
| 130 | 130 | nil |
| 131 | 131 | end |
| @@ -147,7 +147,7 @@ class App < Sinatra::Application · 15 unmodified lines | ||
| 147 | 147 | end |
| 148 | 148 | |
| 149 | 149 | def doc_index_page? |
| 150 | − @doc && request.path == "/#{@doc['slug']}/" | |
| 150 | + @doc && (request.path == "/#{@doc['slug']}/" || request.path == "/#{@doc['slug_without_version']}/") | |
| 151 | 151 | end |
| 152 | 152 | |
| 153 | 153 | def query_string_for_redirection |