Financial-Times/polyfill-service — pull request #30 by samgiles (2014-07-17 15:11:37+00:00)
Title: Issue27/simpleapi

This includes quite a large commit as I've restructured the code base slightly. (Perhaps should've done this in a separate PR) I've done this to add a couple of unit tests to the function which transforms the query string parameters into objects that the library can work with.

It takes the string: "polyfillname|flag1|flag2|flag3,polyfillname2|flag1|flag3" and parses it into a _nicer_ datastructure:

```JS
[
{
name: "polyfillname",
flags: ["flag1", "flag2", "flag3"]
},
{
name: "polyfillname2",
flags: ["flag1", "flag3"]
}
]
```

Main changes include:

- Renamed `sources/` to `polyfills/`
- Moved service specific files into `service/`
- Moved non-specific library files into `lib/`
- By default polyfills are included based on user agent:

```SH
# Included only if Polyfill.name is required by the UA as identified in config.
/polyfill.js?features=Polyfill.name
```

- If the `always` flag is defined for a polyfill then it is included regardless of the user agent:

```SH
# Includes Polyfill.name regardless of the UA
/polyfill.js?features=Polyfill.name|always
```

- In anticipation, if the `gated` QS parameter is specified then each polyfill is assigned the `gated` flag. This does not do anything with this request except for set the flag in the data structure (example above).

Closes #27.