~fkfd/sophon

ceed9853e0cb09290a3416e66f285d43052a0984 — Frederick Yin 3 years ago cad8c31
"section=" is removed from edit session init query
2 files changed, 5 insertions(+), 12 deletions(-)

M routes.go
M test/test_edit.py
M routes.go => routes.go +4 -11
@@ 61,18 61,11 @@ func routeWikiRequest(segs []string, query string, clientIP net.Addr) (string, s
			if query == "" {
				// /wiki/<page>/edit
				return "10 Specify which section to edit", ""
			} else if query == "meta" {
				// /wiki/<page>/edit?meta
				sessionID, err := initEditSession(pageName, "meta", clientIP.String())
				if err != nil {
					return "40 " + err.Error(), ""
				}
				return "30 /wiki/" + pageName + "/edit/" + sessionID + "/", ""
			} else if match, _ := regexp.Match("^section=([1-9]\\d*\\.){1,2}$", []byte(query)); match == true {
				// /wiki/<page>/edit?section=<section>
				// where <section> must be a valid section number
			} else if match, _ := regexp.Match("^([1-9]\\d*\\.){1,2}$", []byte(query)); match == true || query == "meta" {
				// /wiki/<page>/edit?<section>
				// where <section> must be "meta" or a valid body section number
				// as defined in docs/wiki_pages.gmi
				sessionID, err := initEditSession(pageName, query[8:], clientIP.String())
				sessionID, err := initEditSession(pageName, query, clientIP.String())
				if err != nil {
					return "40 " + err.Error(), ""
				}

M test/test_edit.py => test/test_edit.py +1 -1
@@ 15,7 15,7 @@ def test_edit(commit=False):
    print("Blank request: pass")

    # initialize new session
    resp = gemini_request("/wiki/test/edit?section=1.1.")
    resp = gemini_request("/wiki/test/edit?1.1.")
    match = re.match(r"^/wiki/test/edit/([0-9a-f]{16})/", resp.meta)
    assert resp.status == 30 and match
    session_id = match.group(1)