Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

WIP: BasePath #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import { parseRoute } from "./parseRoute"

export function Route(props) {
return function(state, actions) {
var location = state.location
var location = state.location;
// Basepath must end with /
if(props.basepath && props.basepath[props.basepath.length] !== "/"){
props.basepath += "/";
}
// Remove basepath from path
if(props.path && ~props.path.indexOf(props.basepath)){
props.path = props.path.split(props.basepath)[1];
}
// Remove basepath from url
if(location.pathname && ~location.pathname.indexOf(props.basepath)){
location.pathname = location.pathname.split(props.basepath)[1];
}
var match = parseRoute(props.path, location.pathname, {
exact: !props.parent
})
Expand Down