0.1.13 • Published 1 year ago

cisurls v0.1.13

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

UIUC CIS API URL Tools

npm version License: MIT Build Status

Some very basic UIUC Course Information Suite(CIS) API URL utilities. Fix URLs from the documentation(from cisapi to cisapp/explorer) to make them plug-and-play, take API URL(cisapp/explorer) and make it courses.illinois.edu web page URL, and maybe more in the future.

A web interface for this module is available at mirth.cc/cisurls-web.

Info

The fixDocumentationURL() function reliably handles:

  • /schedule/ endpoints

It does not handle:

  • /catalog endpoints (use /schedule instead)
  • /gened endpoints (use /schedule/courses instead)
  • /term endpoints (use /schedule instead)
  • /subject endpoints (use /schedule instead)

Installation

Install via npm:

npm install cisurls

Usage

const { fixDocumentationURL, convertCourseURL } = require("cisurls");
// Fix a URL from the UIUC CIS API documentation
const fixedUrl = fixDocumentationURL(
  "http://courses.illinois.edu/cisapi/schedule/courses?year=2012&term=spring§ionTypeCode=LEC§ionTypeCode=Q&collegeCode=KV&creditHours=3&subject=CHEM&sessionId=1&gened=NAT&qp=atomic+structure"
);
console.log(fixedUrl);
// Convert a UIUC CIS API Course URL to a courses.illinois.edu URL
const courseUrl = convertCourseURL(
  "https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml"
);
console.log(courseUrl);

API

fixDocumentationURL(url, addCascade = false)

Fixes a URL from the UIUC CIS API documentation to work with the UIUC CIS Explorer.

Fixes the following:

  • Change “/cisapi” to “/cisapp/explorer”
  • Add .xml before the parameters. For example, change “/courses” to “/courses.xml”
  • Special case of missing & before § in schedule/courses endpoint.

Parameters:

  • url (string): The URL to be fixed.
  • addCascade (boolean, optional): If true, adds the "mode=cascade" parameter to the URL. Default is false.

convertCourseURL(url)

Converts a UIUC CIS API course URL to a courses.illinois.edu web page URL. (Beginning with https://courses.illinois.edu/cisapp/explorer/schedule)

Does the following:

  • Change "/cisapp/explorer" to "/search"
  • Remove ".xml" from the end of the URL
  • Remove query parameters

Parameters:

  • url (string): The URL to be converted.

Throws

Here's an explanation of when these errors can be thrown:

  1. fixDocumentationURL(url, addCascade) and convertCourseURL(url) functions:

    • Both functions will throw an error if the provided url parameter is not a string:

      The "url" parameter must be a string.

    • Both functions will also throw an error if the provided url parameter is an empty string:

      The "url" parameter must not be an empty string.

    • Both functions will throw an error if the provided url parameter is not a valid URL:

      The "url" parameter must be a valid URL.

  2. fixDocumentationURL(url, addCascade) function:

    • If the provided url is not a UIUC CIS API URL:

      The "url" parameter must be a UIUC CIS API URL (like http(s)://courses.illinois.edu/cisapi/).

  3. convertCourseURL(url) function:

    • If the provided url is not a UIUC CIS Explorer URL:

      The "url" parameter must be a UIUC CIS API Explorer course URL (like https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml).

    • If the provided url does not match the pattern of a valid course URL on the UIUC CIS Explorer:

      The "url" parameter must be a UIUC CIS API Explorer course URL (like https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml).

In all these cases, the errors are thrown to ensure that the provided input meets the required format and structure. If any of these conditions are not met, the functions cannot guarantee the correct processing and conversion of the input URL.

Tests

Run tests with Jest:

npm test

License

This project is licensed under the MIT License. See the LICENSE file for more information.

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago