Skip to content

Commit

Permalink
Replace regex with split
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimShtein committed Apr 18, 2024
1 parent 0ab8f7e commit 3b18ec8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/link_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def decompose_link(link)

def extract_doc_path(path)
# take the right part of the path after the '/html/' from the original link
%r{/html/(.*)}.match(path)&.[](1)
path.split('/html/', 2)[1]
end

def navigate_path(path, hash = @toc)
return nil unless hash

split = path.match(%r{([^/]*)/(.*)})
first = split&.[](1) || path
rest = split&.[](2)
split = path.split('/', 2)
first = split[0]
rest = split[1]

inner_hash = hash[first]

Expand Down

0 comments on commit 3b18ec8

Please sign in to comment.