All files ConstUniversalTemplate.js

100% Statements 19/19
100% Branches 8/8
100% Functions 5/5
100% Lines 19/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41          750x 750x       561x 1547x 1547x 1547x 1132x   1547x   1547x 1547x 1138x   1547x   1547x 1521x     26x         561x 778x 778x 778x        
import DefaultTemplate from './DefaultTemplate.js';
import MatchFragment from './MatchFragment.js';
 
export default class ConstUniversalTemplate extends DefaultTemplate {
    constructor () {
        super(...arguments);
        this._initMatchGenerateFunctions(...arguments);
    }
 
    _getMatchFunctions (templateUri) {
        return [(userUri, contextOptions) => {
            const {partName} = contextOptions;
            let templateUriPart = templateUri.getParsedUri(partName);
            if (templateUriPart.isEmpty()) {
                templateUriPart = contextOptions.router.getDefaultPart(partName);
            }
            const templateUriPartString = templateUriPart.toLowerCase(!contextOptions.caseSensitive).toString();
 
            let userUriPart = userUri.getParsedUri(partName);
            if (userUriPart.isEmpty()) {
                userUriPart = contextOptions.router.getDefaultPart(partName);
            }
            const userUriPartString = userUriPart.toLowerCase(!contextOptions.caseSensitive).toString();
 
            if (templateUriPart.isEmpty() || userUriPartString === templateUriPartString) {
                return new MatchFragment(userUriPart.toString());
            }
 
            return null;
        }];
    }
 
    _getGenerateFunctions (templateUri) {
        return [(userParams, contextOptions) => {
            const {partName} = contextOptions;
            const parsedValue = templateUri.getParsedUri(partName);
            return parsedValue;
        }];
    }
}