UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

15 lines (12 loc) 502 B
define(['../string/typecast', './getQuery'], function (typecast, getQuery) { /** * Get query parameter value. */ function getParam(url, param, shouldTypecast){ var regexp = new RegExp('(\\?|&)'+ param + '=([^&]*)'), //matches `?param=value` or `&param=value`, value = $2 result = regexp.exec( getQuery(url) ), val = (result && result[2])? result[2] : null; return shouldTypecast === false? val : typecast(val); } return getParam; });