export interface Result { data: { [key: string]: string } } export function matches(str: string, m: string): Result | undefined { const strParts = str.split('/').slice(1) const mParts = m.split('/').slice(1) if (strParts.length == mParts.length) { const data: { [key: string]: string } = {} for (let i = 0; i < strParts.length; ++i) { if (mParts[i].length > 0 && mParts[i][0] == ':') { const key = mParts[i].substring(1) data[key] = strParts[i] } else { if (strParts[i] !== mParts[i]) { return undefined } } } return { data } } }