agora-server/app/util.py
Nik V 6e45be9b73 protect against / in page title (common in roam exports)
roam's namespace feature recommends the use of / in page titles, but
since we are using a file-based approach here important to filter them
out lest we end up with subfolder madness
2020-11-27 18:32:56 -08:00

25 lines
801 B
Python

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def canonical_wikilink(wikilink):
# hack hack
wikilink = (
wikilink.lower()
.replace(' ', '-')
.replace('\'', '')
.replace(',', '')
.replace('/', '-')
)
return wikilink