cisurls v0.1.13
UIUC CIS API URL Tools
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:
/catalogendpoints (use/scheduleinstead)/genedendpoints (use/schedule/coursesinstead)/termendpoints (use/scheduleinstead)/subjectendpoints (use/scheduleinstead)
Installation
Install via npm:
npm install cisurlsUsage
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): Iftrue, adds the "mode=cascade" parameter to the URL. Default isfalse.
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:
fixDocumentationURL(url, addCascade)andconvertCourseURL(url)functions:Both functions will throw an error if the provided
urlparameter is not a string:The "url" parameter must be a string.Both functions will also throw an error if the provided
urlparameter is an empty string:The "url" parameter must not be an empty string.Both functions will throw an error if the provided
urlparameter is not a valid URL:The "url" parameter must be a valid URL.
fixDocumentationURL(url, addCascade)function:If the provided
urlis not a UIUC CIS API URL:The "url" parameter must be a UIUC CIS API URL (like http(s)://courses.illinois.edu/cisapi/).
convertCourseURL(url)function:If the provided
urlis 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
urldoes 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 testLicense
This project is licensed under the MIT License. See the LICENSE file for more information.