UNPKG

react-routing

Version:

Isomorphic router for React.js applications

40 lines (32 loc) 999 B
/** * React Routing | http://www.kriasoft.com/react-routing * Copyright (c) Konstantin Tarkus <hello@tarkus.me> | The MIT License */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var Match = function Match(route, path, keys, match) { _classCallCheck(this, Match); this.route = route; this.path = path; this.params = Object.create(null); for (var i = 1; i < match.length; i++) { this.params[keys[i - 1].name] = decodeParam(match[i]); } }; function decodeParam(val) { if (!(typeof val === 'string' || val instanceof String)) { return val; } try { return decodeURIComponent(val); } catch (e) { var err = new TypeError('Failed to decode param \'' + val + '\''); err.status = 400; throw err; } } exports['default'] = Match; module.exports = exports['default'];