changed parameter name

This commit is contained in:
Yessiest 2023-04-19 11:56:02 +04:00
parent 3b8632f8a7
commit 695e32bbfa
2 changed files with 11 additions and 12 deletions

17
hyde.rb
View File

@ -36,9 +36,9 @@ module Hyde
# Interchangeable glob/regex/string pattern matching
module PatternMatching
def prep_path(path,safe_regexp: true)
def prep_path(path,match_full_path: false)
raise Exception, "Not permitted" if @lock_methods
@safe_regexp = safe_regexp
@match_full_path = match_full_path
@path = normalize(path) if path.kind_of? String
@path = path if path.kind_of? Regexp
end
@ -53,8 +53,8 @@ module Hyde
# 3) safe regexp means match only the part before the next slash
# 2) a .match? only returns when there are no leftovers
# this forces the matching to work somewhat consistently
test = @path.match normalize_input(path) unless @safe_regexp
test = @path.match split_path[0] if @safe_regexp
test = @path.match normalize_input(path) if @match_full_path
test = @path.match split_path[0] unless @match_full_path
if test and (test.pre_match == "") and (test.post_match == "") then
return true
else
@ -137,8 +137,8 @@ module Hyde
class Probe
include Hyde::PatternMatching
include Hyde::PublicContextControlMethods
def initialize (path, safe_regexp: true, &block_optional)
prep_path path, safe_regexp: safe_regexp
def initialize (path, match_full_path: false, &block_optional)
prep_path path, match_full_path: match_full_path
@block = block_optional
end
def match(request)
@ -201,8 +201,8 @@ module Hyde
class Pathspec
include Hyde::PatternMatching
include Hyde::Handlers
def initialize (path, root_path: nil, safe_regexp: true, &block)
prep_path path, safe_regexp: safe_regexp
def initialize (path, root_path: nil, match_full_path: false, &block)
prep_path path, match_full_path: match_full_path
@chain = []
@handles = {}
@root_override = root_path
@ -266,7 +266,6 @@ module Hyde
end
# passthrough to the next path object
next_pathspec = @chain.find { |x| x.match? cut_path }
puts next_pathspec.inspect
next_pathspec.match request if next_pathspec
unless next_pathspec then
# throw 404 if nowhere to go

View File

@ -1,7 +1,7 @@
require_relative 'hyde'
server = Hyde::Server.new Port: 8000 do
root "/home/yessiest/hyde/test/"
root Dir::pwd+"/test/"
serve "index.html"
index ["index.html"]
path "about" do
@ -16,8 +16,8 @@ server = Hyde::Server.new Port: 8000 do
end
path "uploads" do
index ["index.html"]
serve "**/*.md", safe_regex: false
serve ["*.html","**/*.html"], safe_regex: false
serve "**/*.md", match_full_path: true
serve ["*.html","**/*.html"], match_full_path: true
end
end